MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / authenticateToLinkedNotebookShard

Method authenticateToLinkedNotebookShard

communication/communicationmanager.cpp:676–726  ·  view source on GitHub ↗

Authenticate to a linked notebook

Source from the content-addressed store, hash-verified

674
675// Authenticate to a linked notebook
676bool CommunicationManager::authenticateToLinkedNotebookShard(LinkedNotebook &book) {
677
678 if (!book.noteStoreUrl.isSet()) {
679 QLOG_ERROR() << tr("Linked notebook notestore URL missing.");
680 return false;
681 }
682
683 try {
684 if (linkedNoteStore != NULL)
685 delete linkedNoteStore;
686
687 // Connect to the proper shard
688 linkedNoteStore = new NoteStore(book.noteStoreUrl, authToken);
689 linkedAuthToken = "<Public Notebook>";
690 noteStore = linkedNoteStore;
691
692 // Now, authenticate to the book. Books
693 // without a sharekey are public, so authentication
694 // isn't needed
695 if (!book.shareKey.isSet())
696 return true;
697
698 // We have a share key, so authenticate
699 linkedAuth = noteStore->authenticateToSharedNotebook(book.shareKey, authToken);
700 linkedAuthToken = linkedAuth.authenticationToken;
701 } catch (ThriftException e) {
702 QLOG_ERROR() << "ThriftException:";
703 QLOG_ERROR() << "Exception Type:" << e.type();
704 QLOG_ERROR() << "Exception Msg:" << e.what();
705 error.message = errorWhat(e.what());
706 error.type = CommunicationError::ThriftException;
707 return false;
708 } catch (EDAMUserException e) {
709 QLOG_ERROR() << "EDAMUserException:" << e.errorCode << endl;
710 error.code = e.errorCode;
711 error.type = CommunicationError::EDAMUserException;
712 error.message = errorWhat(e.what());
713 return false;
714 } catch (EDAMSystemException e) {
715 QLOG_ERROR() << "EDAMSystemException";
716 handleEDAMSystemException(e);
717 return false;
718 } catch (EDAMNotFoundException e) {
719 QLOG_ERROR() << "EDAMNotFoundException";
720 // If it is a linked noteboook & it isn't found, then we can just expunge it
721 return false;
722 //handleEDAMNotFoundException(e);
723 return false;
724 }
725 return true;
726}
727
728
729

Callers 1

Calls 4

typeMethod · 0.80
isSetMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected