use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class UserGroupService method authNProviderExistsForDomain.
/**
* Check if a provider exists for the given domain
*
* @param domain
* @return
*/
private boolean authNProviderExistsForDomain(String domain) {
URIQueryResultList providers = new URIQueryResultList();
try {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getAuthnProviderDomainConstraint(domain), providers);
} catch (DatabaseException ex) {
_log.error("Could not query for authn providers to check for existing domain {}", domain, ex.getStackTrace());
throw ex;
}
// check if there is an AuthnProvider contains the given domain and not in disabled state
boolean bExist = false;
Iterator<URI> it = providers.iterator();
while (it.hasNext()) {
URI providerURI = it.next();
AuthnProvider provider = _dbClient.queryObject(AuthnProvider.class, providerURI);
if (provider != null && provider.getDisable() == false) {
bExist = true;
break;
}
}
return bExist;
}
use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class ProvisioningServiceImpl method start.
@Override
public synchronized void start() throws Exception {
initValidator();
initServer();
_server.start();
_svcBeacon.start();
// Launch OpenStack synchronization task if Keystone Authentication Provider exists.
AuthnProvider keystoneProvider = _openStackSynchronizationTask.getKeystoneProvider();
if (keystoneProvider != null && keystoneProvider.getAutoRegCoprHDNImportOSProjects()) {
_openStackSynchronizationTask.start(_openStackSynchronizationTask.getTaskInterval(keystoneProvider));
}
}
use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class ProvisioningServiceImpl method stop.
@Override
public synchronized void stop() throws Exception {
_server.stop();
_dbClient.stop();
AuthnProvider keystoneProvider = _openStackSynchronizationTask.getKeystoneProvider();
if (keystoneProvider != null && keystoneProvider.getAutoRegCoprHDNImportOSProjects()) {
_openStackSynchronizationTask.stop();
}
}
use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class AuthMapper method map.
public static final AuthnProvider map(AuthnCreateParam from) {
AuthnProvider authn = new AuthnProvider();
if (from.getManagerDn() != null) {
authn.setManagerDN(from.getManagerDn());
}
if (from.getManagerPassword() != null) {
authn.setManagerPassword(from.getManagerPassword());
}
if (from.getDisable() != null) {
authn.setDisable(from.getDisable());
}
if (from.getAutoRegCoprHDNImportOSProjects() != null) {
authn.setAutoRegCoprHDNImportOSProjects(from.getAutoRegCoprHDNImportOSProjects());
} else {
authn.setAutoRegCoprHDNImportOSProjects(false);
}
StringSet tenantsSynchronizationOptions = null;
if (from.getTenantsSynchronizationOptions() != null && !from.getTenantsSynchronizationOptions().isEmpty()) {
tenantsSynchronizationOptions = new StringSet();
tenantsSynchronizationOptions.addAll(from.getTenantsSynchronizationOptions());
authn.setTenantsSynchronizationOptions(tenantsSynchronizationOptions);
}
StringSet urlStringSet = null;
if (from.getServerUrls() != null && !from.getServerUrls().isEmpty()) {
urlStringSet = new StringSet();
urlStringSet.addAll(from.getServerUrls());
authn.setServerUrls(urlStringSet);
}
if (from.getMode() != null) {
authn.setMode(from.getMode());
}
if (from.getLabel() != null) {
authn.setLabel(from.getLabel());
}
if (from.getDescription() != null) {
authn.setDescription(from.getDescription());
}
if (from.getGroupAttribute() != null) {
authn.setGroupAttribute(from.getGroupAttribute());
}
StringSet ss = null;
if (from.getGroupWhitelistValues() != null && !from.getGroupWhitelistValues().isEmpty()) {
ss = new StringSet();
ss.addAll(from.getGroupWhitelistValues());
authn.setGroupWhitelistValues(ss);
}
if (from.getDomains() != null && !from.getDomains().isEmpty()) {
StringSet trimmedDomains = new StringSet();
for (String domain : from.getDomains()) {
// Strip whitespace and convert domain to lowercase
trimmedDomains.add(domain.trim().toLowerCase());
}
authn.setDomains(trimmedDomains);
}
if (from.getSearchBase() != null) {
authn.setSearchBase(from.getSearchBase());
}
if (from.getSearchFilter() != null) {
authn.setSearchFilter(from.getSearchFilter());
}
if (from.getSearchScope() != null) {
authn.setSearchScope(from.getSearchScope());
}
if (from.getMaxPageSize() != null) {
authn.setMaxPageSize(from.getMaxPageSize());
}
if (from.getGroupObjectClasses() != null) {
ss = new StringSet();
ss.addAll(from.getGroupObjectClasses());
authn.setGroupObjectClassNames(ss);
}
if (from.getGroupMemberAttributes() != null) {
ss = new StringSet();
ss.addAll(from.getGroupMemberAttributes());
authn.setGroupMemberAttributeTypeNames(ss);
}
return authn;
}
use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class DbClientTest method testQueryByType.
@Test
public void testQueryByType() {
DbClient dbClient = _dbClient;
List<URI> expected = new ArrayList<URI>();
for (int i = 0; i < 10; i++) {
AuthnProvider provider = new AuthnProvider();
provider.setId(URIUtil.createId(AuthnProvider.class));
provider.setLabel("provider" + i);
dbClient.createObject(provider);
expected.add(provider.getId());
}
List<AuthnProvider> providerList = new ArrayList<AuthnProvider>();
for (int i = 10; i < 120; i++) {
AuthnProvider provider = new AuthnProvider();
provider.setId(URIUtil.createId(AuthnProvider.class));
provider.setLabel("provider" + i);
providerList.add(provider);
expected.add(provider.getId());
providerList.add(provider);
}
dbClient.createObject(providerList);
List<URI> match = new ArrayList<URI>(expected);
List<URI> uris = dbClient.queryByType(AuthnProvider.class, true);
Iterator<URI> it = uris.iterator();
Assert.assertTrue(it.hasNext());
int apCnt = 0;
while (it.hasNext()) {
apCnt++;
URI uri = it.next();
Assert.assertTrue(match.contains(uri));
match.remove(uri);
}
Assert.assertEquals(apCnt, 120);
Assert.assertEquals(match.size(), 0);
// query with active flag
List<URI> activeOnly = new ArrayList<URI>(expected);
for (int i = 0; i < 5; i++) {
AuthnProvider provider = new AuthnProvider();
provider.setId(expected.get(i));
provider.setInactive(true);
dbClient.updateAndReindexObject(provider);
activeOnly.remove(expected.get(i));
}
// all query
match = new ArrayList<URI>(expected);
uris = dbClient.queryByType(AuthnProvider.class, false);
it = uris.iterator();
Assert.assertTrue(it.hasNext());
while (it.hasNext()) {
URI uri = it.next();
Assert.assertTrue(String.format("URI %s is not contained in match (%d)", uri.toString(), match.size()), match.contains(uri));
match.remove(uri);
}
Assert.assertEquals(0, match.size());
// active only query - with mixed active/inactive
uris = dbClient.queryByType(AuthnProvider.class, true);
it = uris.iterator();
Assert.assertTrue(it.hasNext());
while (it.hasNext()) {
URI uri = it.next();
Assert.assertTrue(activeOnly.contains(uri));
activeOnly.remove(uri);
}
Assert.assertEquals(0, activeOnly.size());
}
Aggregations