The Jataka, Vol. IV, tr. by W.H.D. Rouse, , at sacred-texts.com
"How should the wise," etc.—This story the Master told while dwelling in Jetavana, about an upright courtier of the king of Kosala.
This man, they say, was most useful to the king, and then the king bestowed on him great honour. The other courtiers being unable to stomach him, accused him to the king of having done things to the king's hurt. The king made enquiry about him, and finding in him no fault, thought, "I see no fault in the man; how can I know whether he be my friend or foe?" Then he thought, "No one, save the Tathāgata,  will be able to decide this question; I will go and ask him." So after he had broken his fast he visited the Master, and said, "How can one tell, Sir, of any man, whether he be friend or foe?" Then the Master replied, "Wise men of old, O king, have pondered this problem, and have questioned the wise about it, and following their advice, have discovered the truth, and renouncing their enemies have paid attention to their friends." This said, at his request, he told a story of the past.
Once upon a time, when Brahmadatta was king of Benares, the Bodhisatta was a courtier who advised him on things spiritual and things temporal. At that time, the rest slandered a certain courtier who was upright. The king seeing no fault in him, asked the Great Being, "Now in what can one tell friend or foe?" repeating the first stanza:
What deeds declare to eye or ear the man that is a foe?"
Then the Great Being repeated these five stanzas to explain the marks of an enemy:
"Your enemies he honours, he cares not for your friends, "No secret tells he to you, your secret he betrays, "He joys not at your welfare, but at your evil fame: "These are the sixteen tokens by which a foe you see  "How should the wise and prudent strive, what will discernment lend,
He will not turn his eyes that way, and answers you with No. 1
Those who would praise your worth, he stays, your slanderers commends.
Speaks never well of what you do, your wisdom will not praise.
Should he receive some dainty, he thinks not of your name,
Nor pities you, nor cries aloud-O, had my friend the same!
These if a wise man sees or hears he knows his enemy 2."
What deeds declare to eye and ear the man that is a friend?"
"Your enemies he honours, he cares not for your friends,
"No secret tells he to you, your secret he betrays,
"He joys not at your welfare, but at your evil fame:
"These are the sixteen tokens by which a foe you see
 "How should the wise and prudent strive, what will discernment lend,
The other, thus questioned in these lines, recited the remaining stanzas:
"Your foes he never honours, he loves to serve your friends, "He tells his secrets to you, your secret ne’er betrays, "He joys to hear your welfare, not in your evil fame: "These are the sixteen tokens in friends established well,
Then in the height of his delight he greets you with his voice.
Those who would slander you, he stays; who praise you, he commends.
Speaks ever well of all you do, your wisdom loves to praise.
Should he receive some dainty, he straight thinks on your name,
And pities you, and cries aloud-O had my friend the same!
Which if a wise man sees or hears he can a true friend tell."
"Your foes he never honours, he loves to serve your friends,
"He tells his secrets to you, your secret ne’er betrays,
"He joys to hear your welfare, not in your evil fame:
"These are the sixteen tokens in friends established well,
 The king, delighted at the speech of the Great Being, gave him the highest honour.
The Master, having ended this discourse, said, "Thus, great king, this question arose in days of yore, even as now, and wise men said their say; by these two-and-thirty signs may friend or foe be known." With those words, he identified the Birth: "At that time, Ānanda was the king, and I myself was the wise courtier."
122:1 This couplet has occurred already in vol. ii. p. 92, of the translation.
122:2 This also occurs above, vol. ii. p. 92, of this translation (two words differ).