I have a text (justified block paragraph) with an author attribution.
If the last line of the text has enough space left to fit the author attribution and some space, then it should be put into that line flushed right.
If the last line of the text doesn't have enough space, the author attribution should go to the next line flushed right, but the last line of the paragraph shouldn't be justified.
Foo bar foobar. Foo bar foobar. Foo bar foobar. Foo bar foobar.
Foo bar foobar. Foo bar foobar. Foo bar foobar. Foo bar foobar.
Foo bar foobar. Foo bar foobar. Foo bar foobar. by the Author
Foo bar foobar. Foo bar foobar. Foo bar foobar. Foo bar foobar.
Foo bar foobar. Foo bar foobar. Foo bar foobar. Foo bar foobar.
Foo bar foobar. Foo bar foobar. Foo bar foobar.
by another Author
How can I achieve this?

proofenvironment uses similar logic to position the QED symbol at the end of a proof -- maybe look at its implementation? – John Wickerson May 09 '13 at 08:00