Search in sources :

Example 1 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class LdapEntry method queryCurrentRecord.

protected LdifRecord queryCurrentRecord(OpsTarget target) throws OpsException {
    LdapService ldapService = OpsContext.get().getInstance(LdapService.class);
    String ldapPassword = ldapService.ldapServerPassword.plaintext();
    String filter = null;
    LdapDN searchBaseDN = getLdapDN();
    return OpenLdapManager.doLdapQuerySingle(target, OpenLdapServer.ADMIN_DN, ldapPassword, searchBaseDN, filter);
}
Also used : LdapService(org.platformlayer.service.openldap.model.LdapService) LdapDN(org.platformlayer.ops.ldap.LdapDN)

Example 2 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class OpenLdapTestHelpers method createLdapServer.

public LdapService createLdapServer() throws OpsException, IOException {
    String id = random.randomAlphanumericString(8);
    Secret ldapServerPassword = randomSecret();
    LdapService service = new LdapService();
    service.dnsName = id + ".test.platformlayer.org";
    service.ldapServerPassword = ldapServerPassword;
    service = context.putItem(id, service);
    service = context.waitForHealthy(service);
    return service;
}
Also used : Secret(org.platformlayer.core.model.Secret) LdapService(org.platformlayer.service.openldap.model.LdapService)

Example 3 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class LdapServiceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    LdapService model = OpsContext.get().getInstance(LdapService.class);
    // TODO: Support package pre-configuration??
    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, DiskImageRecipeBuilder.loadDiskImageResource(getClass(), "DiskImageRecipe.xml"), model.getTags());
    addChild(instance);
    instance.addChild(MetricsInstance.class);
    instance.addChild(LdapMasterPassword.build(model.ldapServerPassword));
    {
        PublicEndpoint endpoint = injected(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = PORT;
        endpoint.backendPort = PORT;
        endpoint.dnsName = model.dnsName;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        instance.addChild(endpoint);
    }
}
Also used : PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) LdapService(org.platformlayer.service.openldap.model.LdapService) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 4 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class GitServerController method getLdapService.

LdapService getLdapService() throws OpsException {
    if (ldapService == null) {
        GitService model = OpsContext.get().getInstance(GitService.class);
        // String ldapGroup = model.ldapGroup;
        LdapService best = null;
        for (LdapService candidate : platformLayer.listItems(LdapService.class)) {
            switch(candidate.getState()) {
                case DELETE_REQUESTED:
                case DELETED:
                    continue;
            }
            // TODO: How to match?
            if (best == null) {
                best = candidate;
                continue;
            }
            throw new UnsupportedOperationException("Selecting between LDAP services not yet implemented");
        }
        if (best == null) {
            throw new IllegalStateException("Cannot find LDAP service: " + model.ldapGroup);
        }
        ldapService = best;
    }
    return ldapService;
}
Also used : GitService(org.platformlayer.service.git.model.GitService) LdapService(org.platformlayer.service.openldap.model.LdapService)

Example 5 with LdapService

use of org.platformlayer.service.openldap.model.LdapService in project platformlayer by platformlayer.

the class GitServerController method buildTemplateModel.

@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
    LdapDomain ldapDomain = getLdapDomain();
    LdapService ldapService = getLdapService();
    LdapDN organizationDN = LdapDN.fromDomainName(ldapDomain.organizationName);
    LdapDN allUsersDN = organizationDN.childDN("ou", "Users");
    LdapDN managerDN = organizationDN.childDN("cn", "Manager");
    LdapDN groupsDN = organizationDN.childDN("ou", "Groups");
    LdapDN gitUsersDN = groupsDN.childDN("cn", "Git");
    // String authLdapUrl = "ldap://192.168.192.67:389/ou=Users,dc=com,dc=fathomscale?uid";
    // String authLDAPBindDN = "cn=Manager,dc=com,dc=fathomscale";
    // String authLDAPBindPassword = "adminsecret";
    // String requireLdapGroup = "cn=Git,ou=Groups,dc=com,dc=fathomscale";
    int port = 389;
    List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(ldapService.getTags(), port);
    EndpointInfo ldapEndpoint = EndpointChooser.preferIpv4().choose(endpoints);
    if (ldapEndpoint == null) {
        throw new OpsException("Cannot find suitable LDAP endpoint");
    }
    // TODO: Maybe we should just reference an LdapGroup
    // TODO: It sucks that we're logging in here as the Manager account
    // LdapGroup -> LdapDomain -> LdapService
    String authLdapUrl = "ldap://" + ldapEndpoint.publicIp + ":389/" + allUsersDN.toLdifEncoded() + "?uid";
    String authLDAPBindDN = managerDN.toLdifEncoded();
    String authLDAPBindPassword = ldapDomain.adminPassword.plaintext();
    String requireLdapGroup = gitUsersDN.toLdifEncoded();
    model.put("AuthLDAPURL", authLdapUrl);
    model.put("AuthLDAPBindDN", authLDAPBindDN);
    model.put("AuthLDAPBindPassword", authLDAPBindPassword);
    model.put("requireLdapGroup", requireLdapGroup);
}
Also used : EndpointInfo(org.platformlayer.core.model.EndpointInfo) OpsException(org.platformlayer.ops.OpsException) LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) LdapService(org.platformlayer.service.openldap.model.LdapService) LdapDN(org.platformlayer.ops.ldap.LdapDN) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint)

Aggregations

LdapService (org.platformlayer.service.openldap.model.LdapService)8 LdapDomain (org.platformlayer.service.openldap.model.LdapDomain)4 InetSocketAddress (java.net.InetSocketAddress)2 LdapDN (org.platformlayer.ops.ldap.LdapDN)2 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)2 GitService (org.platformlayer.service.git.model.GitService)2 OpenLdapTestHelpers (org.platformlayer.service.openldap.tests.OpenLdapTestHelpers)2 PlatformLayerApiTest (org.platformlayer.tests.PlatformLayerApiTest)2 Test (org.testng.annotations.Test)2 EndpointInfo (org.platformlayer.core.model.EndpointInfo)1 Secret (org.platformlayer.core.model.Secret)1 OpsException (org.platformlayer.ops.OpsException)1 Passwords (org.platformlayer.ops.crypto.Passwords)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 GitRepository (org.platformlayer.service.git.model.GitRepository)1