Skip to content

Commit

Permalink
Merge branch 'issue/164' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
noahcampbell committed Jan 12, 2011
2 parents eabbda5 + b68761f commit 2aec5c9
Showing 1 changed file with 18 additions and 7 deletions.
Expand Up @@ -93,6 +93,11 @@
*/
public class JettyCachingLdapLoginModule extends AbstractLoginModule {

/**
* Provider URL
*/
private String _providerUrl;

/**
* Role prefix to remove from ldap group name.
*/
Expand Down Expand Up @@ -565,6 +570,7 @@ public void initialize(Subject subject, CallbackHandler callbackHandler, Map sha

_hostname = (String) options.get("hostname");
_port = Integer.parseInt((String) options.get("port"));
_providerUrl = (String) options.get("providerUrl");
_contextFactory = (String) options.get("contextFactory");
_bindDn = (String) options.get("bindDn");
_bindPassword = (String) options.get("bindPassword");
Expand Down Expand Up @@ -651,15 +657,20 @@ public Hashtable getEnvironment() {
Properties env = new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY, _contextFactory);

if (_hostname != null) {
if (_port != 0) {
env.put(Context.PROVIDER_URL, "ldap://" + _hostname + ":" + _port + "/");
} else {
env.put(Context.PROVIDER_URL, "ldap://" + _hostname + "/");
if(_providerUrl != null) {
env.put(Context.PROVIDER_URL, _providerUrl);
} else {
if (_hostname != null) {
String url = "ldap://" + _hostname + "/";
if (_port != 0) {
url += ":" + _port + "/";
}

Log.warn("Using hostname and port. Use providerUrl instead: " + url);
env.put(Context.PROVIDER_URL, url);
}
}

if (_authenticationMethod != null) {
env.put(Context.SECURITY_AUTHENTICATION, _authenticationMethod);
}
Expand Down

0 comments on commit 2aec5c9

Please sign in to comment.