Search in sources :

Example 6 with AuthnProvider

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;
}
Also used : AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 7 with AuthnProvider

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));
    }
}
Also used : AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider)

Example 8 with AuthnProvider

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();
    }
}
Also used : AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider)

Example 9 with AuthnProvider

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;
}
Also used : AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 10 with AuthnProvider

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());
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Aggregations

AuthnProvider (com.emc.storageos.db.client.model.AuthnProvider)22 URI (java.net.URI)10 StringSet (com.emc.storageos.db.client.model.StringSet)9 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 DbClient (com.emc.storageos.db.client.DbClient)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 StorageOSUserDAO (com.emc.storageos.db.client.model.StorageOSUserDAO)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 Vcenter (com.emc.storageos.db.client.model.Vcenter)2 InternalDbClient (com.emc.storageos.db.client.upgrade.InternalDbClient)2 UserMapping (com.emc.storageos.security.authorization.BasePermissionsHelper.UserMapping)2 List (java.util.List)2 AixSystem (com.emc.aix.AixSystem)1 HpuxSystem (com.emc.hpux.HpuxSystem)1