use of com.cloud.ldap.LdapConfigurationVO in project cosmic by MissionCriticalCloud.
the class LDAPConfigCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
if (getListAll()) {
// return the existing conf
final LdapListConfigurationCmd listConfigurationCmd = new LdapListConfigurationCmd(_ldapManager);
final Pair<List<? extends LdapConfigurationVO>, Integer> result = _ldapManager.listConfigurations(listConfigurationCmd);
final ListResponse<LDAPConfigResponse> response = new ListResponse<>();
final List<LDAPConfigResponse> responses = new ArrayList<>();
if (result.second() > 0) {
final boolean useSSlConfig = _ldapConfiguration.getSSLStatus();
final String searchBaseConfig = _ldapConfiguration.getBaseDn();
final String bindDnConfig = _ldapConfiguration.getBindPrincipal();
for (final LdapConfigurationVO ldapConfigurationVO : result.first()) {
responses.add(createLDAPConfigResponse(ldapConfigurationVO.getHostname(), ldapConfigurationVO.getPort(), useSSlConfig, null, searchBaseConfig, bindDnConfig));
}
}
response.setResponses(responses);
response.setResponseName(getCommandName());
setResponseObject(response);
} else if (getHostname() == null || getPort() == null) {
throw new InvalidParameterValueException("You need to provide hostname, port to configure your LDAP server");
} else {
final boolean result = updateLDAP();
if (result) {
final LDAPConfigResponse lr = createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
lr.setResponseName(getCommandName());
setResponseObject(lr);
}
}
}
use of com.cloud.ldap.LdapConfigurationVO in project cosmic by MissionCriticalCloud.
the class LDAPRemoveCmd method removeLDAP.
private boolean removeLDAP() {
final LdapListConfigurationCmd listConfigurationCmd = new LdapListConfigurationCmd(_ldapManager);
final Pair<List<? extends LdapConfigurationVO>, Integer> result = _ldapManager.listConfigurations(listConfigurationCmd);
for (final LdapConfigurationVO config : result.first()) {
_ldapManager.deleteConfiguration(config.getHostname());
}
return true;
}
use of com.cloud.ldap.LdapConfigurationVO in project cosmic by MissionCriticalCloud.
the class LdapListConfigurationCmd method createLdapConfigurationResponses.
private List<LdapConfigurationResponse> createLdapConfigurationResponses(final List<? extends LdapConfigurationVO> configurations) {
final List<LdapConfigurationResponse> responses = new ArrayList<>();
for (final LdapConfigurationVO resource : configurations) {
final LdapConfigurationResponse configurationResponse = _ldapManager.createLdapConfigurationResponse(resource);
configurationResponse.setObjectName("LdapConfiguration");
responses.add(configurationResponse);
}
return responses;
}
Aggregations