static public void DeleteCredentials(string cmdrname) { CompanionCredentials c = CompanionCredentials.FromFile(cmdrname); if (c != null) { c.Clear(); c.ToFile(); } }
static public State CredentialState(string cmdrname) { CompanionCredentials c = CompanionCredentials.FromFile(cmdrname); if (c != null && c.IsComplete) { return(c.Confirmed ? State.CONFIRMED : State.NEEDS_CONFIRMATION); } else { return(State.NO_CREDENTIALS); } }
static public bool SetDisabled(string cmdrname, bool disabled) { CompanionCredentials c = CompanionCredentials.FromFile(cmdrname); if (c != null && c.IsComplete) // only worth it if complete { c.disablelogin = disabled; c.ToFile(); // and write back return(true); } else { return(false); } }
static public State CredentialState(string cmdrname, out bool disabled) { disabled = false; CompanionCredentials c = CompanionCredentials.FromFile(cmdrname); if (c != null && c.IsComplete) { disabled = c.disablelogin; return(c.Confirmed ? State.CONFIRMED : State.NEEDS_CONFIRMATION); } else { return(State.NO_CREDENTIALS); } }
///<summary>Log in. Throws an exception if it fails</summary> public void LoginAs(string cmdrname) // login with previous credientials stored { if (NeedLogin) { Credentials = CompanionCredentials.FromFile(cmdrname); // if file name missing, will not be complete for login if (Credentials != null) { NeedLogin = false; } else { throw new CompanionAppException("No stored credentials"); } } else { throw new CompanionAppIllegalStateException("Service in incorrect state to login"); } }