Search in sources :

Example 1 with LdapValidationRequest

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;
}
Also used : LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) LdapValidationRequest(com.sequenceiq.cloudbreak.api.model.ldap.LdapValidationRequest) LdapTestResult(com.sequenceiq.cloudbreak.api.model.ldap.LdapTestResult)

Aggregations

LdapTestResult (com.sequenceiq.cloudbreak.api.model.ldap.LdapTestResult)1 LdapValidationRequest (com.sequenceiq.cloudbreak.api.model.ldap.LdapValidationRequest)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1