get ldapSettings

This commit is contained in:
danikov 2012-03-11 13:40:30 +00:00
parent 969141a7eb
commit 709c7bff63
9 changed files with 89 additions and 29 deletions

View File

@ -141,6 +141,8 @@ public class VCloudDirectorMediaType {
public static final String ORG_PASSWORD_POLICY_SETTINGS = "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml"; public static final String ORG_PASSWORD_POLICY_SETTINGS = "application/vnd.vmware.admin.organizationPasswordPolicySettings+xml";
public static final String ORG_LDAP_SETTINGS = "application/vnd.vmware.admin.organizationLdapSettings+xml";
/** /**
* *
* All acceptable media types. * All acceptable media types.
@ -160,6 +162,6 @@ public class VCloudDirectorMediaType {
NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE, CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS, PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS
); );
} }

View File

@ -110,7 +110,7 @@ public class CustomOrgLdapSettings {
public static final String OPEN_LDAP = "OPEN_LDAP"; public static final String OPEN_LDAP = "OPEN_LDAP";
/** /**
* All acceptable {@link OrgLdapSettings#getOrgLdapMode()} values. * All acceptable {@link OrgLdapSettings#getLdapMode()} values.
* <p/> * <p/>
* This list must be updated whenever a new mode is added. * This list must be updated whenever a new mode is added.
*/ */

View File

@ -29,6 +29,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -62,19 +63,20 @@ import com.google.common.base.Objects.ToStringHelper;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OrgLdapSettings", propOrder = { @XmlRootElement(name = "OrgLdapSettings")
"orgLdapMode", @XmlType(propOrder = {
"ldapMode",
"customUsersOu", "customUsersOu",
"customOrgLdapSettings" "customOrgLdapSettings"
}) })
public class OrgLdapSettings extends ResourceType<OrgLdapSettings> { public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public static final class LdapMode { public static final class LdapMode {
public static final String NONE = "none"; public static final String NONE = "NONE";
public static final String SYSTEM = "system"; public static final String SYSTEM = "SYSTEM";
public static final String CUSTOM = "custom"; public static final String CUSTOM = "CUSTOM";
/** /**
* All acceptable {@link OrgLdapSettings#getOrgLdapMode()} values. * All acceptable {@link OrgLdapSettings#getLdapMode()} values.
* <p/> * <p/>
* This list must be updated whenever a new mode is added. * This list must be updated whenever a new mode is added.
*/ */
@ -93,15 +95,15 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public static class Builder extends ResourceType.Builder<OrgLdapSettings> { public static class Builder extends ResourceType.Builder<OrgLdapSettings> {
private String orgLdapMode; private String ldapMode;
private String customUsersOu; private String customUsersOu;
private CustomOrgLdapSettings customOrgLdapSettings; private CustomOrgLdapSettings customOrgLdapSettings;
/** /**
* @see OrgLdapSettings#getOrgLdapMode() * @see OrgLdapSettings#getLdapMode()
*/ */
public Builder orgLdapMode(String orgLdapMode) { public Builder ldapMode(String ldapMode) {
this.orgLdapMode = orgLdapMode; this.ldapMode = ldapMode;
return this; return this;
} }
@ -123,7 +125,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
public OrgLdapSettings build() { public OrgLdapSettings build() {
OrgLdapSettings orgLdapSettings = new OrgLdapSettings(href, type, links, OrgLdapSettings orgLdapSettings = new OrgLdapSettings(href, type, links,
orgLdapMode, customUsersOu, customOrgLdapSettings); ldapMode, customUsersOu, customOrgLdapSettings);
return orgLdapSettings; return orgLdapSettings;
} }
@ -171,7 +173,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
} }
public Builder fromOrgLdapSettings(OrgLdapSettings in) { public Builder fromOrgLdapSettings(OrgLdapSettings in) {
return fromResourceType(in) return fromResourceType(in)
.orgLdapMode(in.getOrgLdapMode()) .ldapMode(in.getLdapMode())
.customUsersOu(in.getCustomUsersOu()) .customUsersOu(in.getCustomUsersOu())
.customOrgLdapSettings(in.getCustomOrgLdapSettings()); .customOrgLdapSettings(in.getCustomOrgLdapSettings());
} }
@ -183,9 +185,9 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
} }
public OrgLdapSettings(URI href, String type, Set<Link> links, public OrgLdapSettings(URI href, String type, Set<Link> links,
String orgLdapMode, String customUsersOu, CustomOrgLdapSettings customOrgLdapSettings) { String ldapMode, String customUsersOu, CustomOrgLdapSettings customOrgLdapSettings) {
super(href, type, links); super(href, type, links);
this.orgLdapMode = orgLdapMode; this.ldapMode = ldapMode;
this.customUsersOu = customUsersOu; this.customUsersOu = customUsersOu;
this.customOrgLdapSettings = customOrgLdapSettings; this.customOrgLdapSettings = customOrgLdapSettings;
} }
@ -193,7 +195,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@XmlElement(name = "OrgLdapMode") @XmlElement(name = "OrgLdapMode")
protected String orgLdapMode; protected String ldapMode;
@XmlElement(name = "CustomUsersOu") @XmlElement(name = "CustomUsersOu")
protected String customUsersOu; protected String customUsersOu;
@XmlElement(name = "CustomOrgLdapSettings") @XmlElement(name = "CustomOrgLdapSettings")
@ -207,8 +209,8 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
* {@link String } * {@link String }
* *
*/ */
public String getOrgLdapMode() { public String getLdapMode() {
return orgLdapMode; return ldapMode;
} }
/** /**
@ -243,7 +245,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
return false; return false;
OrgLdapSettings that = OrgLdapSettings.class.cast(o); OrgLdapSettings that = OrgLdapSettings.class.cast(o);
return super.equals(that) && return super.equals(that) &&
equal(orgLdapMode, that.orgLdapMode) && equal(ldapMode, that.ldapMode) &&
equal(customUsersOu, that.customUsersOu) && equal(customUsersOu, that.customUsersOu) &&
equal(customOrgLdapSettings, that.customOrgLdapSettings); equal(customOrgLdapSettings, that.customOrgLdapSettings);
} }
@ -251,7 +253,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), return Objects.hashCode(super.hashCode(),
orgLdapMode, ldapMode,
customUsersOu, customUsersOu,
customOrgLdapSettings); customOrgLdapSettings);
} }
@ -259,7 +261,7 @@ public class OrgLdapSettings extends ResourceType<OrgLdapSettings> {
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string() return super.string()
.add("orgLdapMode", orgLdapMode) .add("orgLdapMode", ldapMode)
.add("customUsersOu", customUsersOu) .add("customUsersOu", customUsersOu)
.add("customOrgLdapSettings", customOrgLdapSettings); .add("customOrgLdapSettings", customOrgLdapSettings);
} }

View File

@ -33,6 +33,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
@ -65,8 +66,16 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
// GET /admin/org/{id}/settings/general // GET /admin/org/{id}/settings/general
// PUT /admin/org/{id}/settings/general // PUT /admin/org/{id}/settings/general
// GET /admin/org/{id}/settings/ldap /**
* @see AdminOrgClient#getPasswordPolicy(URI)
*/
@GET
@Path("/settings/ldap")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OrgLdapSettings> getLdapSettings(@EndpointParam URI orgRef);
/** /**
* @see AdminOrgClient#getPasswordPolicy(URI) * @see AdminOrgClient#getPasswordPolicy(URI)

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
@ -56,6 +57,18 @@ public interface AdminOrgClient extends OrgClient {
// GET /admin/org/{id}/settings/ldap // GET /admin/org/{id}/settings/ldap
/**
* Retrieves LDAP settings for an organization.
*
* <pre>
* GET /admin/org/{id}/settings/ldap
* </pre>
*
* @param orgRef the reference for the admin org
* @return the ldap settings
*/
OrgLdapSettings getLdapSettings(URI orgRef);
/** /**
* Retrieves password policy settings for an organization. * Retrieves password policy settings for an organization.
* *

View File

@ -598,9 +598,9 @@ public class Checks {
public static void checkLdapSettings(OrgLdapSettings settings) { public static void checkLdapSettings(OrgLdapSettings settings) {
// Check optional fields // Check optional fields
// NOTE customUsersOu cannot be checked // NOTE customUsersOu cannot be checked
if (settings.getOrgLdapMode() != null) { if (settings.getLdapMode() != null) {
assertTrue(LdapMode.ALL.contains(settings.getOrgLdapMode()), String.format(REQUIRED_VALUE_OBJECT_FMT, assertTrue(LdapMode.ALL.contains(settings.getLdapMode()), String.format(REQUIRED_VALUE_OBJECT_FMT,
"LdapMode", "OrdLdapSettings", settings.getOrgLdapMode(), Iterables.toString(OrgLdapSettings.LdapMode.ALL))); "LdapMode", "OrdLdapSettings", settings.getLdapMode(), Iterables.toString(OrgLdapSettings.LdapMode.ALL)));
} }
if (settings.getCustomOrgLdapSettings() != null) { if (settings.getCustomOrgLdapSettings() != null) {
checkCustomOrgLdapSettings(settings.getCustomOrgLdapSettings()); checkCustomOrgLdapSettings(settings.getCustomOrgLdapSettings());

View File

@ -25,6 +25,7 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
@ -64,7 +65,30 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
// PUT /admin/org/{id}/settings/general // PUT /admin/org/{id}/settings/general
// GET /admin/org/{id}/settings/ldap @Test
public void testGetLdapSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/admin/ldapSettings.xml",
VCloudDirectorMediaType.ORG_LDAP_SETTINGS)
.httpResponseBuilder().build());
OrgLdapSettings expected = ldapSettings();
assertEquals(client.getAdminOrgClient().getLdapSettings(orgRef.getURI()), expected);
}
public static final OrgLdapSettings ldapSettings() {
return OrgLdapSettings.builder()
.type("application/vnd.vmware.admin.organizationLdapSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap"))
.ldapMode("NONE")
.build();
}
@Test @Test
public void testGetPasswordPolicy() { public void testGetPasswordPolicy() {

View File

@ -24,6 +24,7 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings; import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
@ -85,7 +86,12 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// PUT /admin/org/{id}/settings/general // PUT /admin/org/{id}/settings/general
// GET /admin/org/{id}/settings/ldap @Test(testName = "GET /admin/org/{id}/settings/ldap")
public void getLdapSettings() {
OrgLdapSettings ldapSettings = orgClient.getLdapSettings(orgRef.getURI());
Checks.checkLdapSettings(ldapSettings);
}
@Test(testName = "GET /admin/org/{id}/settings/passwordPolicy") @Test(testName = "GET /admin/org/{id}/settings/passwordPolicy")
public void testGetPasswordPolicy() { public void testGetPasswordPolicy() {

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<OrgLdapSettings xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.admin.organizationLdapSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<OrgLdapMode>NONE</OrgLdapMode>
</OrgLdapSettings>