@SuppressWarnings({"checkstyle:BooleanExpressionComplexity"})
    protected void validateAuthenticationInfo(Hashtable<String, Object> environment)
            throws AuthenticationException {
        // validate when using Simple auth both principal and credentials are set
        if (SIMPLE_AUTHENTICATION_MECHANISM_NAME.equals(environment.get(Context.SECURITY_AUTHENTICATION))) {

            // only validate credentials if we have a non-empty principal
            if (environment.get(Context.SECURITY_PRINCIPAL) != null
                    && StringUtils.hasText(String.valueOf(environment.get(Context.SECURITY_PRINCIPAL)))) {

                Object credentials = environment.get(Context.SECURITY_CREDENTIALS);

                // from the FAQ, we need to check for empty credentials:
                // http://docs.oracle.com/javase/tutorial/jndi/ldap/faq.html
                if (credentials == null
                        || (credentials instanceof byte[] && ((byte[]) credentials).length <= 0)
                        || (credentials instanceof char[] && ((char[]) credentials).length <= 0)
                        || (String.class.isInstance(credentials) && !StringUtils.hasText(String.valueOf(credentials)))) {

                    throw new javax.naming.AuthenticationException("LDAP Simple authentication requires both a "
                            + "principal and credentials.");
                }
            }
        }
    }
Validates the configuration in the JNDI <code>environment</code> settings and throws an exception if a problem
exists.
<p/>
This implementation will throw a {@link AuthenticationException} if the authentication mechanism is set to
'simple', the principal is non-empty, and the credentials are empty (as per
<a href="http://tools.ietf.org/html/rfc4513#section-5.1.2">rfc4513 section-5.1.2</a>).

@param environment the JNDI environment settings to be validated
@throws AuthenticationException if a configuration problem is detected
core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java