Skip to content

Commit

Permalink
support ldap login
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfu committed Jun 18, 2016
1 parent bb7c66e commit e8147f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public class ConstUtils {

public static List<String> SUPER_MANAGER;

/**
* ldap登陆
*/
public static String DEFAULT_LDAP_URL = "";
public static String LDAP_URL = DEFAULT_LDAP_URL;

/**
* 是否为调试
*/
Expand Down Expand Up @@ -199,6 +205,7 @@ public static String getRedisMigrateToolCmd() {
public static String DEFAULT_CACHECLOUD_BASE_DIR = "/opt";
public static String CACHECLOUD_BASE_DIR = DEFAULT_CACHECLOUD_BASE_DIR;


static {
ResourceBundle applicationResourceBundle = ResourceBundle.getBundle("application");
IS_DEBUG = "true".equals(applicationResourceBundle.getString("isDebug"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

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

Expand All @@ -21,18 +22,21 @@ public class LoginUtil {
private final static Logger logger = LoggerFactory.getLogger(LoginUtil.class);

public static boolean passportCheck(String username, String password) {

// maybe your login code or below ldap
/*
//LDAP登陆地址
String ldapUrl = ConstUtils.LDAP_URL;
if (StringUtils.isBlank(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", "ldap://ldap.xx.com");
env.put("java.naming.provider.url", ldapUrl);
env.put("java.naming.security.authentication", "simple");
env.put("java.naming.security.principal", username + "@xx.com");
env.put("java.naming.security.principal", username);
env.put("java.naming.security.credentials", password);
DirContext ctx = null;
try {
Expand All @@ -51,7 +55,6 @@ public static boolean passportCheck(String username, String password) {
}
}
}
*/
return true;
}
}

0 comments on commit e8147f1

Please sign in to comment.