both the tale of the cave and the tale of Gyges' ring of invisibility.
Tolkien almost certainly would have read Plato's Republic, as well as Herodotus
(who wrote a different version of the tale of Gyges' ring) and Homer (the
granddaddy of fantasy
writers).
“I dislike Allegory - the conscious and intentional allegory - yet any attempt to explain the purport of myth or fairytale must use allegorical language. (And, of course, the more 'life' a story has the more readily will it be susceptible of allegorical interpretations: while the better a deliberate allegory is made the more nearly will it be acceptable just as a story.)” (From Tolkien Letter # 131.)