code: public Principal authenticate() throws AlpineAuthenticationException {
          LOGGER.debug("Attempting to authenticate user: " + username);
          final ManagedUserAuthenticationService userService = new ManagedUserAuthenticationService(username, password);
          try{
  	        final Principal principal = userService.authenticate();
  	        if (principal != null) {
  	            return principal;
  	        }
          }catch(AlpineAuthenticationException e){
              // If LDAP is enabled, a second attempt to authenticate the credentials will be
              // made against LDAP so we skip this validation exception. However, if the ManagedUser does exist, 
              // return the correct error
              if (!LDAP_ENABLED || e.getCauseType() != AlpineAuthenticationException.CauseType.INVALID_CREDENTIALS) {
                  throw e;
              }
          }
          if (LDAP_ENABLED) {
              final LdapAuthenticationService ldapService = new LdapAuthenticationService(username, password);
              return ldapService.authenticate();
          }
          // This should never happen, but do not want to return null
          throw new AlpineAuthenticationException(AlpineAuthenticationException.CauseType.OTHER);
      }
docs: Attempts to authenticate the credentials internally first and if not  successful,
  checks to see if LDAP is enabled or not. If enabled, a second attempt to authenticate
  the credentials will be made, but this time against the directory service.
  @return a Principal upon successful authentication
  @throws AlpineAuthenticationException upon authentication failure
  @since 1.0.0