public Object lookup(String name, Class requiredType) throws NamingException {
        Object jndiObject = lookup(name);
        if (requiredType != null && !requiredType.isInstance(jndiObject)) {
            String msg = "Jndi object acquired under name '" + name + "' is of type ["
                    + jndiObject.getClass().getName() + "] and not assignable to the required type ["
                    + requiredType.getName() + "].";
            throw new NamingException(msg);
        }
        return jndiObject;
    }
Look up the object with the given name in the current JNDI context.

@param name         the JNDI name of the object
@param requiredType type the JNDI object must match. Can be an interface or
                    superclass of the actual class, or <code>null</code> for any match. For example,
                    if the value is <code>Object.class</code>, this method will succeed whatever
                    the class of the returned instance.
@return object found (cannot be <code>null</code>; if a not so well-behaved
JNDI implementations returns null, a NamingException gets thrown)
@throws NamingException if there is no object with the given
                        name bound to JNDI
core/src/main/java/org/apache/shiro/jndi/JndiTemplate.java