The "two conditions" listed above are straight out of Sanhedrin 98a:
R. Johanan also said: The son of David will come only in a generation that is either altogether righteous or altogether wicked. 'in a generation that is altogether righteous,' — as it is written, Thy people also shall be all righteous: they shall inherit the land for ever.30 'Or altogether wicked,' — as it is written, And he saw that there was no man, and wondered that there was no intercessor;31 and it is [elsewhere] written, For mine own sake, even for mine own sake, will I do it.32 - Source This is literally Jewish theology as it has been since soon after the Bar Kochba Revolt. I suspect it is interpreted from Leviticus 26. One wonders if Sabbateans planted this little gem. I wonder how old it is.