mirror of
https://github.com/nicolabs/ldap-plugin.git
synced 2025-09-07 05:14:24 +02:00
Merged revisions 22092 via svnmerge from
https://svn.dev.java.net/svn/hudson/branches/rc ........ r22092 | kohsuke | 2009-09-24 10:13:43 -0700 (Thu, 24 Sep 2009) | 1 line Because Util.fixNull() is overloaded, Groovy won't be able to find the right version. Also added a regression test. ........ git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22093 71c3de6d-444a-0410-be80-ed276b4c234a Originally-Committed-As: 9b981befbe3dad8f07d9a03ec04141780d036c1d
This commit is contained in:
parent
3460c0955e
commit
cca01e704d
|
@ -25,7 +25,9 @@ package hudson.security;
|
|||
|
||||
import groovy.lang.Binding;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import static hudson.Util.fixNull;
|
||||
import static hudson.Util.fixEmptyAndTrim;
|
||||
import static hudson.Util.fixEmpty;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.User;
|
||||
|
@ -274,14 +276,14 @@ public class LDAPSecurityRealm extends SecurityRealm {
|
|||
@DataBoundConstructor
|
||||
public LDAPSecurityRealm(String server, String rootDN, String userSearchBase, String userSearch, String groupSearchBase, String managerDN, String managerPassword) {
|
||||
this.server = server.trim();
|
||||
this.managerDN = Util.fixEmpty(managerDN);
|
||||
this.managerPassword = Scrambler.scramble(Util.fixEmpty(managerPassword));
|
||||
if(Util.fixEmptyAndTrim(rootDN)==null) rootDN=Util.fixNull(inferRootDN(server));
|
||||
this.managerDN = fixEmpty(managerDN);
|
||||
this.managerPassword = Scrambler.scramble(fixEmpty(managerPassword));
|
||||
if(fixEmptyAndTrim(rootDN)==null) rootDN= fixNull(inferRootDN(server));
|
||||
this.rootDN = rootDN.trim();
|
||||
this.userSearchBase = userSearchBase.trim();
|
||||
userSearch = Util.fixEmptyAndTrim(userSearch);
|
||||
this.userSearchBase = fixNull(userSearchBase).trim();
|
||||
userSearch = fixEmptyAndTrim(userSearch);
|
||||
this.userSearch = userSearch!=null ? userSearch : "uid={0}";
|
||||
this.groupSearchBase = Util.fixEmptyAndTrim(groupSearchBase);
|
||||
this.groupSearchBase = fixEmptyAndTrim(groupSearchBase);
|
||||
}
|
||||
|
||||
public String getServerUrl() {
|
||||
|
@ -326,7 +328,7 @@ public class LDAPSecurityRealm extends SecurityRealm {
|
|||
}
|
||||
|
||||
public String getLDAPURL() {
|
||||
return getServerUrl()+'/'+Util.fixNull(rootDN);
|
||||
return getServerUrl()+'/'+ fixNull(rootDN);
|
||||
}
|
||||
|
||||
public SecurityComponents createSecurityComponents() {
|
||||
|
@ -449,7 +451,7 @@ public class LDAPSecurityRealm extends SecurityRealm {
|
|||
String rolePrefix;
|
||||
boolean convertToUpperCase;
|
||||
public AuthoritiesPopulatorImpl(InitialDirContextFactory initialDirContextFactory, String groupSearchBase) {
|
||||
super(initialDirContextFactory, groupSearchBase);
|
||||
super(initialDirContextFactory, fixNull(groupSearchBase));
|
||||
// These match the defaults in acegi 1.0.5; set again to store in non-private fields:
|
||||
setRolePrefix("ROLE_");
|
||||
setConvertToUpperCase(true);
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, Sun Microsystems
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package hudson.security
|
||||
|
||||
import org.jvnet.hudson.test.HudsonTestCase
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class LDAPSecurityRealmTest extends HudsonTestCase {
|
||||
/**
|
||||
* This minimal test still causes the 'LDAPBindSecurityRealm.groovy' to be parsed, allowing us to catch
|
||||
* basic syntax errors and such.
|
||||
*/
|
||||
void testGroovyBeanDef() {
|
||||
hudson.securityRealm = new LDAPSecurityRealm("ldap.itd.umich.edu",null,null,null,null,null,null);
|
||||
println hudson.securityRealm.securityComponents // force the component creation
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ bindAuthenticator(BindAuthenticator2,initialDirContextFactory) {
|
|||
userSearch = ldapUserSearch;
|
||||
}
|
||||
|
||||
authoritiesPopulator(AuthoritiesPopulatorImpl, initialDirContextFactory, Util.fixNull(instance.groupSearchBase)) {
|
||||
authoritiesPopulator(AuthoritiesPopulatorImpl, initialDirContextFactory, instance.groupSearchBase) {
|
||||
// see DefaultLdapAuthoritiesPopulator for other possible configurations
|
||||
searchSubtree = true;
|
||||
groupSearchFilter = "(| (member={0}) (uniqueMember={0}) (memberUid={1}))";
|
||||
|
|
Loading…
Reference in a new issue