Search in sources :

Example 1 with LdapConfigurationVO

use of org.apache.cloudstack.ldap.LdapConfigurationVO in project cloudstack by apache.

the class LDAPConfigCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    if (getListAll()) {
        // return the existing conf
        LdapListConfigurationCmd listConfigurationCmd = new LdapListConfigurationCmd(_ldapManager);
        Pair<List<? extends LdapConfigurationVO>, Integer> result = _ldapManager.listConfigurations(listConfigurationCmd);
        ListResponse<LDAPConfigResponse> response = new ListResponse<LDAPConfigResponse>();
        List<LDAPConfigResponse> responses = new ArrayList<LDAPConfigResponse>();
        if (result.second() > 0) {
            boolean useSSlConfig = _ldapConfiguration.getSSLStatus();
            String searchBaseConfig = _ldapConfiguration.getBaseDn();
            String bindDnConfig = _ldapConfiguration.getBindPrincipal();
            for (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 {
        boolean result = updateLDAP();
        if (result) {
            LDAPConfigResponse lr = createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
            lr.setResponseName(getCommandName());
            setResponseObject(lr);
        }
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) LdapConfigurationVO(org.apache.cloudstack.ldap.LdapConfigurationVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LDAPConfigResponse(org.apache.cloudstack.api.response.LDAPConfigResponse) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with LdapConfigurationVO

use of org.apache.cloudstack.ldap.LdapConfigurationVO in project cloudstack by apache.

the class LDAPRemoveCmd method removeLDAP.

private boolean removeLDAP() {
    LdapListConfigurationCmd listConfigurationCmd = new LdapListConfigurationCmd(_ldapManager);
    Pair<List<? extends LdapConfigurationVO>, Integer> result = _ldapManager.listConfigurations(listConfigurationCmd);
    for (LdapConfigurationVO config : result.first()) {
        _ldapManager.deleteConfiguration(config.getHostname());
    }
    return true;
}
Also used : LdapConfigurationVO(org.apache.cloudstack.ldap.LdapConfigurationVO) List(java.util.List)

Example 3 with LdapConfigurationVO

use of org.apache.cloudstack.ldap.LdapConfigurationVO in project cloudstack by apache.

the class LdapListConfigurationCmd method createLdapConfigurationResponses.

private List<LdapConfigurationResponse> createLdapConfigurationResponses(final List<? extends LdapConfigurationVO> configurations) {
    final List<LdapConfigurationResponse> responses = new ArrayList<LdapConfigurationResponse>();
    for (final LdapConfigurationVO resource : configurations) {
        final LdapConfigurationResponse configurationResponse = _ldapManager.createLdapConfigurationResponse(resource);
        configurationResponse.setObjectName("LdapConfiguration");
        responses.add(configurationResponse);
    }
    return responses;
}
Also used : LdapConfigurationResponse(org.apache.cloudstack.api.response.LdapConfigurationResponse) LdapConfigurationVO(org.apache.cloudstack.ldap.LdapConfigurationVO) ArrayList(java.util.ArrayList)

Aggregations

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