Search in sources :

Example 6 with PersistenceEntryManager

use of org.gluu.persist.PersistenceEntryManager in project oxAuth by GluuFederation.

the class AuthenticationService method externalAuthenticate.

private boolean externalAuthenticate(String keyValue, String password) {
    for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
        GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
        PersistenceEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
        String primaryKey = "uid";
        if (StringHelper.isNotEmpty(ldapAuthConfig.getPrimaryKey())) {
            primaryKey = ldapAuthConfig.getPrimaryKey();
        }
        String localPrimaryKey = "uid";
        if (StringHelper.isNotEmpty(ldapAuthConfig.getLocalPrimaryKey())) {
            localPrimaryKey = ldapAuthConfig.getLocalPrimaryKey();
        }
        boolean authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey, false);
        if (authenticated) {
            return authenticated;
        }
    }
    return false;
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 7 with PersistenceEntryManager

use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.

the class StandaloneCustomScriptManagerTest method main.

public static void main(String[] args) {
    if (System.getenv("PYTHON_HOME") == null) {
        System.err.println("PYTHON_HOME environment variable is not defined");
        System.exit(-1);
    }
    PersistenceEntryManager persistenceEntryManager = createLdapEntryManager();
    StandaloneCustomScriptManager customScriptManager = new StandaloneCustomScriptManager(persistenceEntryManager, "ou=scripts,o=gluu", "/opt/gluu/python/libs");
    // Register required external scripts
    SampleIdpExternalScriptService sampleIdpExternalScriptService = new SampleIdpExternalScriptService();
    customScriptManager.registerExternalScriptService(sampleIdpExternalScriptService);
    // Init script manager and load scripts
    customScriptManager.init();
    // Call script
    Object context = new SampleContext(System.currentTimeMillis());
    sampleIdpExternalScriptService.executeExternalUpdateAttributesMethods(context);
    // Reload script if needed
    customScriptManager.reload();
    // Call script
    Object context2 = new SampleContext(System.currentTimeMillis());
    sampleIdpExternalScriptService.executeExternalUpdateAttributesMethods(context2);
    // Destroy custom script manager and scripts
    customScriptManager.destory();
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) StandaloneCustomScriptManager(org.gluu.service.custom.script.StandaloneCustomScriptManager)

Example 8 with PersistenceEntryManager

use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.

the class ConfigurationFactory method createPersistenceEntryManager.

private PersistenceEntryManager createPersistenceEntryManager() {
    Properties connectionProperties = preparePersistanceProperties();
    PersistenceEntryManagerFactory persistenceEntryManagerFactory = persistanceFactoryService.getPersistenceEntryManagerFactory(persistenceConfiguration);
    PersistenceEntryManager persistenceEntryManager = persistenceEntryManagerFactory.createEntryManager(connectionProperties);
    LOG.info("Created PersistenceEntryManager: {} with operation service: {}", new Object[] { persistenceEntryManager, persistenceEntryManager.getOperationService() });
    return persistenceEntryManager;
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) PersistenceEntryManagerFactory(org.gluu.persist.PersistenceEntryManagerFactory) Properties(java.util.Properties)

Example 9 with PersistenceEntryManager

use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.

the class SchemaService method removeObjectClassWithDefinition.

private void removeObjectClassWithDefinition(String objectClassDefinition) {
    SchemaEntry schemaEntry = new SchemaEntry();
    schemaEntry.setDn(getDnForSchema());
    schemaEntry.addObjectClass(objectClassDefinition);
    log.debug("Removing objectClass: {}", schemaEntry);
    PersistenceEntryManager ldapPersistenceEntryManager = getPersistenceEntryManager();
    ldapPersistenceEntryManager.remove(schemaEntry);
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) SchemaEntry(org.gluu.model.SchemaEntry)

Example 10 with PersistenceEntryManager

use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.

the class SchemaService method removeStringAttribute.

/**
 * Remove string attribute
 *
 * @param attributeType
 *            Attribute type name
 * @throws Exception
 */
public void removeStringAttribute(String attributeType) throws Exception {
    SchemaEntry schema = getSchema();
    String attributeTypeDefinition = getAttributeTypeDefinition(schema, attributeType);
    if (attributeTypeDefinition != null) {
        SchemaEntry schemaEntry = new SchemaEntry();
        schemaEntry.setDn(getDnForSchema());
        schemaEntry.addAttributeType(attributeTypeDefinition);
        log.debug("Removing attributeType: {}", schemaEntry);
        PersistenceEntryManager ldapPersistenceEntryManager = getPersistenceEntryManager();
        ldapPersistenceEntryManager.remove(schemaEntry);
    }
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) SchemaEntry(org.gluu.model.SchemaEntry)

Aggregations

PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)38 Properties (java.util.Properties)8 SchemaEntry (org.gluu.model.SchemaEntry)7 ArrayList (java.util.ArrayList)6 ApplicationScoped (javax.enterprise.context.ApplicationScoped)5 Produces (javax.enterprise.inject.Produces)5 Named (javax.inject.Named)5 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)5 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)5 PersistenceEntryManagerFactory (org.gluu.persist.PersistenceEntryManagerFactory)4 Filter (org.gluu.search.filter.Filter)4 GluuLdapConfiguration (org.gluu.model.ldap.GluuLdapConfiguration)3 GluuInumMap (org.gluu.oxtrust.ldap.cache.model.GluuInumMap)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 CustomScriptType (org.gluu.model.custom.script.CustomScriptType)2 CacheCompoundKey (org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)2 ApplicationInitializedEvent (org.gluu.service.cdi.event.ApplicationInitializedEvent)2