use of io.jans.orm.sql.model.TableMapping in project jans by JanssenProject.
the class SqlConnectionProvider method getTableMappingByKey.
public TableMapping getTableMappingByKey(String key, String objectClass) {
String tableName = objectClass;
Map<String, String> columTypes = tableColumnsMap.get(tableName);
if ("_".equals(key)) {
return new TableMapping("", tableName, objectClass, columTypes);
}
String[] baseNameParts = key.split("_");
if (ArrayHelper.isEmpty(baseNameParts)) {
throw new KeyConversionException("Failed to determine base key part!");
}
TableMapping tableMapping = new TableMapping(baseNameParts[0], tableName, objectClass, columTypes);
return tableMapping;
}
use of io.jans.orm.sql.model.TableMapping in project jans by JanssenProject.
the class SqlOperationServiceImpl method updateEntry.
@Override
public boolean updateEntry(String key, String objectClass, List<AttributeDataModification> mods) throws UnsupportedOperationException, PersistenceException {
Instant startTime = OperationDurationUtil.instance().now();
TableMapping tableMapping = connectionProvider.getTableMappingByKey(key, objectClass);
boolean result = updateEntryImpl(tableMapping, key, mods);
Duration duration = OperationDurationUtil.instance().duration(startTime);
OperationDurationUtil.instance().logDebug("SQL operation: modify, duration: {}, table: {}, key: {}, mods: {}", duration, tableMapping.getTableName(), key, mods);
return result;
}
use of io.jans.orm.sql.model.TableMapping in project jans by JanssenProject.
the class SqlOperationServiceImpl method delete.
@Override
public boolean delete(String key, String objectClass) throws EntryNotFoundException {
Instant startTime = OperationDurationUtil.instance().now();
TableMapping tableMapping = connectionProvider.getTableMappingByKey(key, objectClass);
boolean result = deleteImpl(tableMapping, key);
Duration duration = OperationDurationUtil.instance().duration(startTime);
OperationDurationUtil.instance().logDebug("SQL operation: delete, duration: {}, table: {}, key: {}", duration, tableMapping.getTableName(), key);
return result;
}
use of io.jans.orm.sql.model.TableMapping in project jans by JanssenProject.
the class SqlOperationServiceImpl method authenticateImpl.
private boolean authenticateImpl(String key, String password, String objectClass) throws SearchException {
Instant startTime = OperationDurationUtil.instance().now();
boolean result = false;
if (password != null) {
try {
List<AttributeData> attributes = lookup(key, objectClass, USER_PASSWORD);
Object userPasswordObj = null;
for (AttributeData attribute : attributes) {
if (StringHelper.equalsIgnoreCase(attribute.getName(), USER_PASSWORD)) {
userPasswordObj = attribute.getValue();
}
}
String userPassword = null;
if (userPasswordObj instanceof String) {
userPassword = (String) userPasswordObj;
}
if (userPassword != null) {
if (persistenceExtension == null) {
result = PasswordEncryptionHelper.compareCredentials(password, userPassword);
} else {
result = persistenceExtension.compareHashedPasswords(password, userPassword);
}
}
} catch (EntryConvertationException ex) {
throw new SearchException(String.format("Failed to get '%s' attribute", USER_PASSWORD), ex);
}
}
Duration duration = OperationDurationUtil.instance().duration(startTime);
TableMapping tableMapping = connectionProvider.getTableMappingByKey(key, objectClass);
OperationDurationUtil.instance().logDebug("SQL operation: bind, duration: {}, table: {}, key: {}", duration, tableMapping.getTableName(), key);
return result;
}
Aggregations