use of com.sequenceiq.cloudbreak.api.model.ldap.LdapValidationRequest in project cloudbreak by hortonworks.
the class LdapController method testLdapConnection.
@Override
public LdapTestResult testLdapConnection(LDAPTestRequest ldapTestRequest) {
String existingLDAPConfigName = ldapTestRequest.getName();
LdapValidationRequest validationRequest = ldapTestRequest.getValidationRequest();
if (existingLDAPConfigName == null && validationRequest == null) {
throw new BadRequestException("Either an existing resource 'id' or an LDAP 'validationRequest' needs to be specified in the request. ");
}
LdapTestResult ldapTestResult = new LdapTestResult();
try {
if (existingLDAPConfigName != null) {
LdapConfig ldapConfig = ldapConfigService.getByName(existingLDAPConfigName, authenticatedUserService.getCbUser());
ldapConfigValidator.validateLdapConnection(ldapConfig);
} else {
ldapConfigValidator.validateLdapConnection(validationRequest);
}
ldapTestResult.setConnectionResult("connected");
} catch (BadRequestException e) {
ldapTestResult.setConnectionResult(e.getMessage());
}
return ldapTestResult;
}
Aggregations