I threw together a very simple implementation of a Realm that uses MongoDB as an authentication source for Tomcat. I wrote this because I couldn’t find an implementation that deferred to the MongoClient and supported the syntax of the the MongoClientURI. I needed a Realm that could connect to multiple members of a replicaSet and which could understand preferences for reading from either a primary or a secondary. I also needed something simple and configurable enough to allow the user to point to whichever collection and field name contained the necessary credential information. In other words, I need the MongoRealm equivalent of the JDBCRealm, and none of the existing solutions fit these requirements.