private LdapContextFactory ensureContextFactory() {
        if (this.ldapContextFactory == null) {

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("No LdapContextFactory specified - creating a default instance.");
            }

            JndiLdapContextFactory defaultFactory = new JndiLdapContextFactory();
            defaultFactory.setUrl(this.url);
            defaultFactory.setSystemUsername(this.systemUsername);
            defaultFactory.setSystemPassword(this.systemPassword);

            this.ldapContextFactory = defaultFactory;
        }
        return this.ldapContextFactory;
    }
Configures the {@link LdapContextFactory} implementation that is used to create LDAP connections for
authentication and authorization.  If this is set, the {@link LdapContextFactory} provided will be used.
Otherwise, a {@link JndiLdapContextFactory} instance will be created based on the properties specified
in this realm.

@param ldapContextFactory the factory to use - if not specified, a default factory will be created automatically.
core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java