Search in sources :

Example 1 with LdapConfigurationVO

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);
        }
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) LdapConfigurationVO(com.cloud.ldap.LdapConfigurationVO) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) LDAPConfigResponse(com.cloud.api.response.LDAPConfigResponse) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with LdapConfigurationVO

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;
}
Also used : LdapConfigurationVO(com.cloud.ldap.LdapConfigurationVO) List(java.util.List)

Example 3 with LdapConfigurationVO

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;
}
Also used : LdapConfigurationResponse(com.cloud.api.response.LdapConfigurationResponse) LdapConfigurationVO(com.cloud.ldap.LdapConfigurationVO) ArrayList(java.util.ArrayList)

Aggregations

LdapConfigurationVO (com.cloud.ldap.LdapConfigurationVO)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 LDAPConfigResponse (com.cloud.api.response.LDAPConfigResponse)1 LdapConfigurationResponse (com.cloud.api.response.LdapConfigurationResponse)1 ListResponse (com.cloud.api.response.ListResponse)1 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)1