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);
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations