Skip to content
Permalink
Browse files
[FIXED JENKINS-27763] reworked the UI.
De-emphasize the domain name setting in the ADSI mode, but once the user
selects that, expose the entire set of options that the LDAP mode has.
  • Loading branch information
kohsuke committed Apr 7, 2015
1 parent 2076e0d commit b54418bf613cfc9d03b470b55199fb4a998d3926
Showing 6 changed files with 77 additions and 122 deletions.
@@ -23,9 +23,7 @@
*/
package hudson.plugins.active_directory;

import static hudson.Util.fixEmpty;
import static hudson.plugins.active_directory.ActiveDirectoryUnixAuthenticationProvider.toDC;

import com.sun.jndi.ldap.LdapCtxFactory;
import com4j.typelibs.ado20.ClassFactory;
import groovy.lang.Binding;
import hudson.Extension;
@@ -40,20 +38,22 @@
import hudson.security.TokenBasedRememberMeServices2;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import hudson.util.ListBoxModel.Option;
import hudson.util.Secret;
import hudson.util.spring.BeanBuilder;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.acegisecurity.Authentication;
import org.acegisecurity.AuthenticationException;
import org.acegisecurity.AuthenticationManager;
import org.acegisecurity.BadCredentialsException;
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.springframework.dao.DataAccessException;
import org.springframework.web.context.WebApplicationContext;

import javax.naming.Context;
import javax.naming.NamingEnumeration;
@@ -69,23 +69,19 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.acegisecurity.Authentication;
import org.acegisecurity.AuthenticationException;
import org.acegisecurity.AuthenticationManager;
import org.acegisecurity.BadCredentialsException;
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import org.acegisecurity.userdetails.UserDetails;
import org.acegisecurity.userdetails.UserDetailsService;
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.springframework.dao.DataAccessException;
import org.springframework.web.context.WebApplicationContext;

import com.sun.jndi.ldap.LdapCtxFactory;
import static hudson.Util.*;
import static hudson.plugins.active_directory.ActiveDirectoryUnixAuthenticationProvider.*;

/**
* {@link SecurityRealm} that talks to Active Directory.
@@ -144,16 +140,24 @@ public class ActiveDirectorySecurityRealm extends AbstractPasswordBasedSecurityR
public final boolean removeIrrelevantGroups;

public ActiveDirectorySecurityRealm(String domain, String site, String bindName, String bindPassword, String server) {
this(domain,site,bindName,bindPassword,server,GroupLookupStrategy.AUTO,false);
this(domain, site, bindName, bindPassword, server, GroupLookupStrategy.AUTO, false);
}

public ActiveDirectorySecurityRealm(String domain, String site, String bindName, String bindPassword, String server, GroupLookupStrategy groupLookupStrategy) {
this(domain,site,bindName,bindPassword,server,groupLookupStrategy,false);
}

@DataBoundConstructor
public ActiveDirectorySecurityRealm(String domain, String site, String bindName,
String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups) {
this(domain,site,bindName,bindPassword,server,groupLookupStrategy,removeIrrelevantGroups,domain!=null);
}

@DataBoundConstructor
// as Java signature, this binding doesn't make sense, so please don't use this constructor
public ActiveDirectorySecurityRealm(String domain, String site, String bindName,
String bindPassword, String server, GroupLookupStrategy groupLookupStrategy, boolean removeIrrelevantGroups, Boolean customDomain) {
if (customDomain!=null && !customDomain)
domain = null;
this.domain = fixEmpty(domain);
this.site = fixEmpty(site);
this.bindName = fixEmpty(bindName);
@@ -634,7 +638,7 @@ public int compareTo(PrioritizedSocketInfo that) {
throw x;
}

LOGGER.fine(ldapServer+" resolved to "+result);
LOGGER.fine(ldapServer + " resolved to " + result);
return result;
}
}

This file was deleted.

@@ -2,49 +2,25 @@
<j:choose>
<j:when test="${descriptor.canDoNativeAuth()}">
<!-- code path for ActiveDirectoryAuthenticationProvider: running on Windows -->
<f:nested>
<f:validateButton with="domain,server" title="${%Test}" method="validate"/>
</f:nested>
<f:advanced>
<f:entry title="${%Domain Name}" field="domain" help="/plugin/active-directory/help/domain-name-windows.html">
<f:textbox />
</f:entry>
<f:entry title="${%Domain controller}" field="server">
<f:textbox />
</f:entry>
<f:entry field="removeIrrelevantGroups" title="${%Remove irrelevant groups}">
<f:checkbox />
</f:entry>
</f:advanced>
<f:entry><!-- get some indentation -->
<table style="width:100%">
<f:optionalBlock title="${%Specify custom Active Directory domain name}"
inline="true" name="customDomain" checked="${instance.domain!=null}"
help="/plugin/active-directory/help/domain-name-windows.html">
<f:entry title="${%Domain Name}" field="domain">
<f:textbox />
</f:entry>
<st:include page="configAdvanced.jelly" class="${descriptor.clazz}"/>
</f:optionalBlock>
</table>
</f:entry>
</j:when>
<j:otherwise>
<!-- code path for ActiveDirectoryUnixAuthenticationProvider: running on Unix -->
<f:entry title="${%Domain Name}" field="domain" help="/plugin/active-directory/help/domain-name-unix.html">
<f:textbox />
</f:entry>
<f:advanced>
<f:entry title="${%Domain controller}" field="server">
<f:textbox />
</f:entry>
<f:entry field="site" title="${%Site}">
<f:textbox />
</f:entry>
<f:entry field="bindName" title="${%Bind DN}">
<f:textbox />
</f:entry>
<f:entry field="bindPassword" title="${%Bind Password}">
<f:password />
</f:entry>
<f:entry field="groupLookupStrategy" title="${%Group Membership Lookup Strategy}">
<f:select />
</f:entry>
<f:entry field="removeIrrelevantGroups" title="${%Remove irrelevant groups}">
<f:checkbox />
</f:entry>
</f:advanced>
<f:nested>
<f:validateButton with="domain,site,bindName,bindPassword,server" title="${%Test}" method="validate"/>
</f:nested>
<st:include page="configAdvanced.jelly" class="${descriptor.clazz}"/>
</j:otherwise>
</j:choose>
</j:jelly>
@@ -0,0 +1,25 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:advanced>
<f:entry title="${%Domain controller}" field="server">
<f:textbox />
</f:entry>
<f:entry field="site" title="${%Site}">
<f:textbox />
</f:entry>
<f:entry field="bindName" title="${%Bind DN}">
<f:textbox />
</f:entry>
<f:entry field="bindPassword" title="${%Bind Password}">
<f:password />
</f:entry>
<f:entry field="groupLookupStrategy" title="${%Group Membership Lookup Strategy}">
<f:select />
</f:entry>
<f:entry field="removeIrrelevantGroups" title="${%Remove irrelevant groups}">
<f:checkbox />
</f:entry>
</f:advanced>
<f:nested>
<f:validateButton with="domain,server,site,bindName,bindPassword" title="${%Test}" method="validate"/>
</f:nested>
</j:jelly>
@@ -0,0 +1 @@
Server=Servidor
@@ -1,2 +1 @@
Domain\ Name=Domain-Name
Server=Server

0 comments on commit b54418b

Please sign in to comment.