use of org.graylog.security.authservice.test.AuthServiceBackendTestResult in project graylog2-server by Graylog2.
the class LDAPAuthServiceBackend method testConnection.
@Override
public AuthServiceBackendTestResult testConnection(@Nullable AuthServiceBackendDTO existingBackendConfig) {
final LDAPAuthServiceBackendConfig testConfig = buildTestConfig(existingBackendConfig);
final LDAPConnectorConfig config = testConfig.getLDAPConnectorConfig();
if (config.serverList().size() == 1) {
return testSingleConnection(config, config.serverList().get(0));
}
// Test each server separately, so we can see the result for each
final List<AuthServiceBackendTestResult> testResults = config.serverList().stream().map(server -> testSingleConnection(config, server)).collect(Collectors.toList());
if (testResults.stream().anyMatch(res -> !res.isSuccess())) {
return AuthServiceBackendTestResult.createFailure("Test failure", testResults.stream().map(r -> {
if (r.isSuccess()) {
return r.message();
} else {
return r.message() + " : " + String.join(",", r.errors());
}
}).collect(Collectors.toList()));
} else {
return AuthServiceBackendTestResult.createSuccess("Successfully connected to " + config.serverList());
}
}
use of org.graylog.security.authservice.test.AuthServiceBackendTestResult in project graylog2-server by Graylog2.
the class ADAuthServiceBackend method testConnection.
@Override
public AuthServiceBackendTestResult testConnection(@Nullable AuthServiceBackendDTO existingBackendConfig) {
final ADAuthServiceBackendConfig testConfig = buildTestConfig(existingBackendConfig);
final LDAPConnectorConfig config = testConfig.getLDAPConnectorConfig();
if (config.serverList().size() == 1) {
return testSingleConnection(config, config.serverList().get(0));
}
// Test each server separately, so we can see the result for each
final List<AuthServiceBackendTestResult> testResults = config.serverList().stream().map(server -> testSingleConnection(config, server)).collect(Collectors.toList());
if (testResults.stream().anyMatch(res -> !res.isSuccess())) {
return AuthServiceBackendTestResult.createFailure("Test failure", testResults.stream().map(r -> {
if (r.isSuccess()) {
return r.message();
} else {
return r.message() + " : " + String.join(",", r.errors());
}
}).collect(Collectors.toList()));
} else {
return AuthServiceBackendTestResult.createSuccess("Successfully connected to " + config.serverList());
}
}
Aggregations