internal ENCredentials(string host, AuthenticationResult authenticationResult) { Host = host; EdamUserId = authenticationResult.User.Id.ToString(); NoteStoreUrl = authenticationResult.NoteStoreUrl; WebApiUrlPrefix = authenticationResult.WebApiUrlPrefix; AuthenticationToken = authenticationResult.AuthenticationToken; ExpirationDate = authenticationResult.Expiration.ToDateTime(); }
internal void SetAuthenticationResultForBusiness(AuthenticationResult result) { if (result == null) { return; } ENAuthCacheEntry entry = ENAuthCacheEntry.EntryWithResult(result); BusinessCache = entry; }
internal void SetAuthenticationResultForLinkedNotebook(AuthenticationResult result, string guid) { if (result == null) { return; } ENAuthCacheEntry entry = ENAuthCacheEntry.EntryWithResult(result); LinkedCache[guid] = entry; }
/// <summary> /// Updated cached authentication information with the values in the specified /// AuthenticationResult. /// </summary> private void updateAuth(AuthenticationResult result) { authToken = result.AuthenticationToken; noteStoreUrl = result.NoteStoreUrl; // Calculate the token expiration time, accounting for clock skew long durationMillis = result.Expiration - result.CurrentTime; TimeSpan duration = TimeSpan.FromMilliseconds(durationMillis); tokenExpires = DateTime.UtcNow.Add(duration); }
internal ENCredentials(string host, AuthenticationResult authenticationResult) { this.Host = host; this.EdamUserId = authenticationResult.User.Id.ToString(); this.NoteStoreUrl = authenticationResult.NoteStoreUrl; this.WebApiUrlPrefix = authenticationResult.WebApiUrlPrefix; this.AuthenticationToken = authenticationResult.AuthenticationToken; this.ExpirationDate = authenticationResult.Expiration.ToDateTime(); //registryStore = New ENRegistry }
internal static ENAuthCacheEntry EntryWithResult(AuthenticationResult result) { if (result == null) { return null; } ENAuthCacheEntry entry = new ENAuthCacheEntry(); entry.AuthResult = result; entry.CachedDate = DateTime.Now; return entry; }
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 0: if (field.Type == TType.Struct) { Success = new AuthenticationResult(); Success.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 1: if (field.Type == TType.Struct) { UserException = new Evernote.EDAM.Error.EDAMUserException(); UserException.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Struct) { SystemException = new Evernote.EDAM.Error.EDAMSystemException(); SystemException.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
private void saveAndPublishAuthResult(AuthenticationResult authResult) { //save and publish results for future reference this.authenticationToken = authResult.AuthenticationToken; servicebus.Publish<AuthenticationEvent>(new AuthenticationEvent() { AuthenticationResult = authResult, Sender = this }); }
/// <summary> /// Logs into Evernote. /// </summary> public static void Login( string username, string password ) { // Login to Evernote. log.Info( "Logging in to Evernote..." ); authentication = Authenticate( username, password ); }
internal List<Entity.Notebook> ReadEvernoteNotes(String edamBaseUrl, AuthenticationResult authResult) { string authToken = authResult.AuthenticationToken; NoteStore.Client noteStore = EvernoteHelper.GetNoteStoreClient(edamBaseUrl, authResult.User); List<Notebook> notebooks = noteStore.listNotebooks(authToken); int nbCount=1; foreach (Entity.Notebook enNotebook in enNotebooks) { int intProgress = Helper.GetNotebookProgress(nbCount++, enNotebooks.Count, 20, 60); UpdateProgress(intProgress); NoteFilter nf = new NoteFilter(); nf.NotebookGuid = enNotebook.Guid; NoteList nl = noteStore.findNotes(authToken, nf, 0, 500);//500 notes limit per notebook foreach (Note note in nl.Notes) { UpdateProgress(intProgress, "Retrieving " + enNotebook.Name + ", " + note.Title); Entity.Note enNote = new Entity.Note(); enNote.Title = note.Title; enNote.ShortDateString = note.Updated.ToString(); string enmlContent = noteStore.getNoteContent(authToken, note.Guid); enNote.LoadXml(enmlContent); if (enNotebook.Notes == null) enNotebook.Notes = new List<Entity.Note>(); enNotebook.Notes.Add(enNote); } } enNotebooks.Sort(delegate(Entity.Notebook p1, Entity.Notebook p2) { return p1.Name.CompareTo(p2.Name); }); return enNotebooks; }
internal List<Entity.Notebook> ReadEvernoteNotebooks(String edamBaseUrl, AuthenticationResult authResult) { string authToken = authResult.AuthenticationToken; NoteStore.Client noteStore = EvernoteHelper.GetNoteStoreClient(edamBaseUrl, authResult.User); List<Notebook> notebooks = noteStore.listNotebooks(authToken); UpdateProgress("Retrieving Notebook List"); foreach (Notebook notebook in notebooks) { Entity.Notebook enNotebook = new Entity.Notebook(); enNotebook.Name = (notebook.Stack + " " + notebook.Name).Trim(); enNotebook.Guid = notebook.Guid; int intProgress = Helper.GetNotebookProgress(enNotebooks.Count, notebooks.Count, 1, 20); UpdateProgress(intProgress); NoteFilter nf = new NoteFilter(); nf.NotebookGuid = enNotebook.Guid; NoteList nl = noteStore.findNotes(authToken, nf, 0, 1); if (nl.Notes.Count > 0) { enNotebooks.Add(enNotebook); } } enNotebooks.Sort(delegate(Entity.Notebook p1, Entity.Notebook p2) { return p1.Name.CompareTo(p2.Name); }); return enNotebooks; }