use of org.gluu.persist.PersistenceEntryManagerFactory in project oxAuth by GluuFederation.
the class AppInitializer method createPersistenceAuthEntryManager.
@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME)
public List<PersistenceEntryManager> createPersistenceAuthEntryManager() {
List<PersistenceEntryManager> persistenceAuthEntryManagers = new ArrayList<PersistenceEntryManager>();
if (this.persistenceAuthConfigs.size() == 0) {
return persistenceAuthEntryManagers;
}
PersistenceEntryManagerFactory persistenceEntryManagerFactory = applicationFactory.getPersistenceEntryManagerFactory(LdapEntryManagerFactory.class);
List<Properties> persistenceAuthProperties = prepareAuthConnectionProperties(this.persistenceAuthConfigs, persistenceEntryManagerFactory.getPersistenceType());
log.trace("Attempting to create LDAP auth PersistenceEntryManager with properties: {}", persistenceAuthProperties);
for (int i = 0; i < persistenceAuthProperties.size(); i++) {
PersistenceEntryManager persistenceAuthEntryManager = persistenceEntryManagerFactory.createEntryManager(persistenceAuthProperties.get(i));
log.debug("Created {}#{}: {}", new Object[] { ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, i, persistenceAuthEntryManager });
persistenceAuthEntryManagers.add(persistenceAuthEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(persistenceAuthProperties.get(i), persistenceAuthEntryManager);
}
return persistenceAuthEntryManagers;
}
use of org.gluu.persist.PersistenceEntryManagerFactory 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;
}
use of org.gluu.persist.PersistenceEntryManagerFactory in project oxTrust by GluuFederation.
the class CacheRefreshTimer method prepareLdapServerConnection.
private LdapServerConnection prepareLdapServerConnection(CacheRefreshConfiguration cacheRefreshConfiguration, GluuLdapConfiguration ldapConfiguration, boolean useLocalConnection) {
String ldapConfig = ldapConfiguration.getConfigId();
if (useLocalConnection) {
return new LdapServerConnection(ldapConfig, ldapEntryManager, getBaseDNs(ldapConfiguration));
}
PersistenceEntryManagerFactory entryManagerFactory = applicationFactory.getPersistenceEntryManagerFactory(LdapEntryManagerFactory.class);
String persistenceType = entryManagerFactory.getPersistenceType();
Properties ldapProperties = toLdapProperties(entryManagerFactory, ldapConfiguration);
Properties ldapDecryptedProperties = encryptionService.decryptAllProperties(ldapProperties);
// Try to get updated password via script
BindCredentials bindCredentials = externalCacheRefreshService.executeExternalGetBindCredentialsMethods(ldapConfig);
String bindPasswordPropertyKey = persistenceType + "#" + PropertiesDecrypter.BIND_PASSWORD;
if (bindCredentials != null) {
log.error("Using updated password which got from getBindCredentials method");
ldapDecryptedProperties.setProperty(persistenceType + ".bindDN", bindCredentials.getBindDn());
ldapDecryptedProperties.setProperty(bindPasswordPropertyKey, bindCredentials.getBindPassword());
}
if (log.isTraceEnabled()) {
Properties clonedLdapDecryptedProperties = (Properties) ldapDecryptedProperties.clone();
if (clonedLdapDecryptedProperties.getProperty(bindPasswordPropertyKey) != null) {
clonedLdapDecryptedProperties.setProperty(bindPasswordPropertyKey, "REDACTED");
}
log.trace("Attempting to create PersistenceEntryManager with properties: {}", clonedLdapDecryptedProperties);
}
PersistenceEntryManager customPersistenceEntryManager = entryManagerFactory.createEntryManager(ldapDecryptedProperties);
log.info("Created Cache Refresh PersistenceEntryManager: {}", customPersistenceEntryManager);
if (!customPersistenceEntryManager.getOperationService().isConnected()) {
log.error("Failed to connect to LDAP server using configuration {}", ldapConfig);
return null;
}
return new LdapServerConnection(ldapConfig, customPersistenceEntryManager, getBaseDNs(ldapConfiguration));
}
use of org.gluu.persist.PersistenceEntryManagerFactory in project oxAuth by GluuFederation.
the class AppInitializer method createPersistenceAuthEntryManager.
/*
* Utility method which can be used in custom scripts
*/
public PersistenceEntryManager createPersistenceAuthEntryManager(GluuLdapConfiguration persistenceAuthConfig) {
PersistenceEntryManagerFactory persistenceEntryManagerFactory = applicationFactory.getPersistenceEntryManagerFactory();
Properties persistenceConnectionProperties = prepareAuthConnectionProperties(persistenceAuthConfig, persistenceEntryManagerFactory.getPersistenceType());
PersistenceEntryManager persistenceAuthEntryManager = persistenceEntryManagerFactory.createEntryManager(persistenceConnectionProperties);
log.debug("Created custom authentication PersistenceEntryManager: {}", persistenceAuthEntryManager);
externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(persistenceConnectionProperties, persistenceAuthEntryManager);
return persistenceAuthEntryManager;
}
Aggregations