public static async Task <UserPublicKey> GetAsync(this KnownPublicKeys knownPublicKeys, EmailAddress email, LogOnIdentity identity)
        {
            UserPublicKey key = knownPublicKeys.PublicKeys.FirstOrDefault(upk => upk.Email == email);

            if (key != null && New <UserPublicKeyUpdateStatus>().Status(key) == PublicKeyUpdateStatus.RecentlyUpdated)
            {
                return(key);
            }

            if (New <AxCryptOnlineState>().IsOffline)
            {
                return(key);
            }

            if (identity == LogOnIdentity.Empty || identity.UserEmail == EmailAddress.Empty)
            {
                return(key);
            }

            IAccountService accountService = New <LogOnIdentity, IAccountService>(identity);

            if (await accountService.IsAccountSourceLocalAsync())
            {
                return(key);
            }

            if (!New <LicensePolicy>().Capabilities.Has(LicenseCapability.KeySharing) && email != _licenseAuthorityEmail)
            {
                return(key);
            }

            AccountStorage          accountStorage = new AccountStorage(New <LogOnIdentity, IAccountService>(identity));
            CustomMessageParameters invitationMessageParameters = new CustomMessageParameters(new CultureInfo(New <UserSettings>().MessageCulture), New <UserSettings>().CustomInvitationMessage);
            UserPublicKey           userPublicKey = await accountStorage.GetOtherUserInvitePublicKeyAsync(email, invitationMessageParameters).Free();

            if (userPublicKey != null)
            {
                knownPublicKeys.AddOrReplace(userPublicKey);
                New <UserPublicKeyUpdateStatus>().SetStatus(userPublicKey, PublicKeyUpdateStatus.RecentlyUpdated);
            }
            return(userPublicKey);
        }