Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public class LdapAuthenticationHandler implements AuthenticationHandler {
*/
public static final String ENABLE_START_TLS = TYPE + ".enablestarttls";

/**
* Constant for disabling the host name verification for this handler.
*/
private static final String DISABLE_HOSTNAME_VERIFICATION = TYPE +
".hostname.verification.disable";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also add this new config in core-site default.


private String ldapDomain;
private String baseDN;
private String providerUrl;
Expand Down Expand Up @@ -130,6 +136,15 @@ public void setDisableHostNameVerification(
this.disableHostNameVerification = disableHostNameVerification;
}

/**
* To get the configured value for Host name verification for this handler.
* This method is introduced only for unit testing.
*/
@VisibleForTesting
boolean getDisableHostNameVerification() {
return disableHostNameVerification;
}

@Override
public String getType() {
return TYPE;
Expand All @@ -142,6 +157,8 @@ public void init(Properties config) throws ServletException {
this.ldapDomain = config.getProperty(LDAP_BIND_DOMAIN);
this.enableStartTls =
Boolean.valueOf(config.getProperty(ENABLE_START_TLS, "false"));
this.disableHostNameVerification =
Boolean.valueOf(config.getProperty(DISABLE_HOSTNAME_VERIFICATION, "false"));

if (this.providerUrl == null) {
throw new NullPointerException("The LDAP URI can not be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public void testRequestWithAuthorization() throws Exception {
Assert.assertEquals("bjones", token.getName());
}

@Test
public void testDisableHostNameVerifyConf() throws Exception {
Assert.assertNotNull(handler.getDisableHostNameVerification());
}

@Test(timeout = 60000)
public void testRequestWithWrongCredentials() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
Expand Down