summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-12-10 14:38:10 -0500
committerJames Moger <james.moger@gitblit.com>2013-12-10 14:38:10 -0500
commit4ce3ff698808bcf0fa6e9820673c366f5504861d (patch)
tree43f57c58065770fa4755ed0f6dc22a2780c2f4b4
parentcc47aad618137ee6481c8bc164d8074bd30fde9e (diff)
downloadgitblit-4ce3ff698808bcf0fa6e9820673c366f5504861d.tar.gz
gitblit-4ce3ff698808bcf0fa6e9820673c366f5504861d.zip
Fix LDAP port and bind regressions due to change for issue-343
Change-Id: I76ee581e067a30fb1656c5c62bdf743846f1a767
-rw-r--r--src/main/java/com/gitblit/auth/LdapAuthProvider.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/auth/LdapAuthProvider.java b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
index 7a6b74df..67d98c7f 100644
--- a/src/main/java/com/gitblit/auth/LdapAuthProvider.java
+++ b/src/main/java/com/gitblit/auth/LdapAuthProvider.java
@@ -162,15 +162,20 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
String bindUserName = settings.getString(Keys.realm.ldap.username, "");
String bindPassword = settings.getString(Keys.realm.ldap.password, "");
-
LDAPConnection conn;
if (ldapUrl.getScheme().equalsIgnoreCase("ldaps")) {
// SSL
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
conn = new LDAPConnection(sslUtil.createSSLSocketFactory());
+ if (ldapPort == -1) {
+ ldapPort = 636;
+ }
} else if (ldapUrl.getScheme().equalsIgnoreCase("ldap") || ldapUrl.getScheme().equalsIgnoreCase("ldap+tls")) {
// no encryption or StartTLS
conn = new LDAPConnection();
+ if (ldapPort == -1) {
+ ldapPort = 389;
+ }
} else {
logger.error("Unsupported LDAP URL scheme: " + ldapUrl.getScheme());
return null;
@@ -187,7 +192,11 @@ public class LdapAuthProvider extends UsernamePasswordAuthenticationProvider {
}
}
- if (!StringUtils.isEmpty(bindUserName) || !StringUtils.isEmpty(bindPassword)) {
+ if (StringUtils.isEmpty(bindUserName) && StringUtils.isEmpty(bindPassword)) {
+ // anonymous bind
+ conn.bind(new SimpleBindRequest());
+ } else {
+ // authenticated bind
conn.bind(new SimpleBindRequest(bindUserName, bindPassword));
}