<commit_before>package com.sohu.cache.web.util;

import java.util.Hashtable;

import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sohu.cache.util.ConstUtils;

/**
 * 域账户LDAP登陆简单工具
 * 
 * @author leifu
 * @Time 2014年6月12日
 */
public class LoginUtil {
    
    private final static Logger logger = LoggerFactory.getLogger(LoginUtil.class);

    public static boolean passportCheck(String username, String password) {
        //LDAP登陆地址
        String ldapUrl = ConstUtils.LDAP_URL;
        if (StringUtils.isBlank(ldapUrl) || ConstUtils.NONE.equals(ldapUrl)) {
            logger.warn("ldap url is empty!!");
            return true;
        }
        if (ConstUtils.IS_DEBUG) {
            logger.warn("isDebug=true return");
            return true;
        }
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
        env.put("java.naming.provider.url", ldapUrl);
        env.put("java.naming.security.authentication", "simple");
        env.put("java.naming.security.principal", username);
        env.put("java.naming.security.credentials", password);
        DirContext ctx = null;
        try {
            ctx = new InitialDirContext(env);
            if (ctx != null) {
                return true;
            }
        } catch (Exception e) {
            logger.error("passportCheck: " + e.getMessage(), e);
        } finally {
            if (ctx != null) {
                try {
                    ctx.close();
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        return true;
    }
}
<commit_msg>fix login error<commit_after>package com.sohu.cache.web.util;

import java.util.Hashtable;

import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sohu.cache.util.ConstUtils;

/**
 * 域账户LDAP登陆简单工具
 * 
 * @author leifu
 * @Time 2014年6月12日
 */
public class LoginUtil {
    
    private final static Logger logger = LoggerFactory.getLogger(LoginUtil.class);

    public static boolean passportCheck(String username, String password) {
        //LDAP登陆地址
        String ldapUrl = ConstUtils.LDAP_URL;
        if (StringUtils.isBlank(ldapUrl) || ConstUtils.NONE.equals(ldapUrl)) {
            logger.warn("ldap url is empty!!");
            return true;
        }
        if (ConstUtils.IS_DEBUG) {
            logger.warn("isDebug=true return");
            return true;
        }
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
        env.put("java.naming.provider.url", ldapUrl);
        env.put("java.naming.security.authentication", "simple");
        env.put("java.naming.security.principal", username);
        env.put("java.naming.security.credentials", password);
        DirContext ctx = null;
        try {
            ctx = new InitialDirContext(env);
            if (ctx != null) {
                return true;
            }
        } catch (Exception e) {
            logger.error("username {} passportCheck: " + e.getMessage(), username, e);
        } finally {
            if (ctx != null) {
                try {
                    ctx.close();
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.11732711732711733, 'fraction_numerical': 0.004662004662004662, 'mean_word_length': 1.8950524737631185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5833944', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1150, 'n_words': 210}