func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) { var up keybase1.UserPlusKeys if uid.IsNil() { return up, fmt.Errorf("Nil UID") } arg := NewLoadUserArg(g) arg.UID = uid arg.PublicKeyOptional = true u, err := LoadUser(arg) if err != nil { return up, err } if u == nil { return up, fmt.Errorf("Nil user, nil error from LoadUser") } // export user to UserPlusKeys up.Uid = u.GetUID() up.Username = u.GetNormalizedName().String() if u.GetComputedKeyFamily() != nil { up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys() } return up, nil }
func RunSyncer(s Syncer, uid keybase1.UID, loggedIn bool, sr SessionReader) (err error) { if uid.IsNil() { return NotFoundError{"No UID given to syncer"} } // unnecessary for secret syncer, but possibly useful for tracker syncer. s.Lock() defer s.Unlock() s.G().Log.Debug("+ Syncer.Load(%s)", uid) defer func() { s.G().Log.Debug("- Syncer.Load(%s) -> %s", uid, ErrToOk(err)) }() if err = s.loadFromStorage(uid); err != nil { return } if s.needsLogin() && !loggedIn { s.G().Log.Debug("| Won't sync with server since we're not logged in") return } if err = s.syncFromServer(uid, sr); err != nil { return } if err = s.store(uid); err != nil { return } return }
func lookupMerkleLeaf(g *GlobalContext, uid keybase1.UID, local *User) (f *MerkleUserLeaf, err error) { if uid.IsNil() { err = fmt.Errorf("uid parameter for lookupMerkleLeaf empty") return } q := NewHTTPArgs() q.Add("uid", UIDArg(uid)) f, err = g.MerkleClient.LookupUser(q) if err == nil && f == nil && local != nil { err = fmt.Errorf("User not found in server Merkle tree") } return }
func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) { var up keybase1.UserPlusKeys if uid.IsNil() { return up, fmt.Errorf("Nil UID") } if cacheOK { up, err := g.UserCache.Get(uid) if err == nil { return *up, nil } if err != nil { // not going to bail on cache error, just log it: if _, ok := err.(NotFoundError); !ok { g.Log.Debug("UserCache Get error: %s", err) } } } arg := NewLoadUserArg(g) arg.UID = uid arg.PublicKeyOptional = true u, err := LoadUser(arg) if err != nil { return up, err } if u == nil { return up, fmt.Errorf("Nil user, nil error from LoadUser") } // export user to UserPlusKeys up.Uid = u.GetUID() up.Username = u.GetNormalizedName().String() if u.GetComputedKeyFamily() != nil { up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys() } err = g.UserCache.Insert(&up) if err != nil { g.Log.Debug("UserCache Set error: %s", err) } return up, nil }
func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID) (keybase1.UserPlusKeys, error) { var up keybase1.UserPlusKeys if uid.IsNil() { return up, fmt.Errorf("Nil UID") } arg := NewLoadUserArg(g) arg.UID = uid arg.PublicKeyOptional = true u, err := LoadUser(arg) if err != nil { return up, err } if u == nil { return up, fmt.Errorf("Nil user, nil error from LoadUser") } return u.ExportToUserPlusKeys(keybase1.Time(0)), nil }
func (e *UntrackEngine) loadThem() (them *libkb.User, remoteLink, localLink *libkb.TrackChainLink, err error) { var rLink *libkb.TrackChainLink trackMap := e.arg.Me.IDTable().GetTrackMap() if links, ok := trackMap[e.arg.Username]; ok && (len(links) > 0) { rLink = links[len(links)-1] } var uid keybase1.UID uidTrusted := false if rLink != nil { if uid, err = rLink.GetTrackedUID(); err != nil { return } uidTrusted = true } if uid.IsNil() { res := libkb.ResolveUID(e.arg.Username) if err = res.GetError(); err != nil { return } // This is an untrusted uid. uid = res.GetUID() if uid.IsNil() { err = libkb.NewUntrackError("Could not resolve uid for @%s", e.arg.Username) return } } lLink, err := libkb.LocalTrackChainLinkFor(e.arg.Me.GetUID(), uid, e.G()) if err != nil { return } if rLink == nil && lLink == nil { err = libkb.NewUntrackError("You are not tracking %s", e.arg.Username) return } if !uidTrusted { if lLink == nil { err = libkb.NewUntrackError("Could not verify resolved uid for @%s", e.arg.Username) return } var trackedUsername string trackedUsername, err = lLink.GetTrackedUsername() if err != nil { return } if e.arg.Username != trackedUsername { err = libkb.NewUntrackError("Username mismatch: expected @%s, got @%s", e.arg.Username, trackedUsername) return } uidTrusted = true } them = libkb.NewUserThin(e.arg.Username, uid) remoteLink = rLink localLink = lLink return }