private HttpClient client; // need to use same client to keep the cookies (for now) public MUConnector(PasswordCredential p) { user = p.UserName.ToLower(); //netid must be lowercase (yeah idk either) p.RetrievePassword(); password = p.Password; InitClient(); }
public ICredentials GetCredentials() { PasswordCredential credentials = new PasswordCredential(); try { // If FindAllByResource returns no results an exception is thrown instead of return NULL so this must be in the try/catch credentials = this._passwordVault.FindAllByResource("WANDAppCredentials").FirstOrDefault(); credentials.RetrievePassword(); } catch (Exception e) { credentials = null; } if (credentials == null) return null; else return new NetworkCredential(credentials.UserName, credentials.Password); }
public void Add(PasswordCredential credential) { while (true) { var capture = _credentials; var existing = capture.FirstOrDefault(c => Comparer.Instance.Equals(c, credential)); ImmutableList <PasswordCredential> updated; if (existing == null) { updated = capture.Add(credential); } else { existing.RetrievePassword(); credential.RetrievePassword(); if (existing.Password == credential.Password) { // no change, abort update! return; } updated = capture.Replace(existing, credential); } lock (_updateGate) { if (capture == _credentials) { Persist(updated); _credentials = updated; return; } } } }
public static bool IsCachedCredentialsAvailable(PasswordCredential credential) { if (credential == null) return false; var user = new MobileServiceUser(credential.UserName); credential.RetrievePassword(); user.MobileServiceAuthenticationToken = credential.Password; if (App.MobileService.IsTokenExpired(user)) return false; return true; }
public PclPasswordCredential(PasswordCredential credential) { Credential = credential; Credential.RetrievePassword(); }