use of org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory in project killbill by killbill.
the class DefaultTenantDao method create.
@Override
public void create(final TenantModelDao entity, final InternalCallContext context) throws TenantApiException {
// Create the salt and password
final ByteSource salt = rng.nextBytes();
// Hash the plain-text password with the random salt and multiple iterations and then Base64-encode the value (requires less space than Hex)
final String hashedPasswordBase64 = new SimpleHash(KillbillCredentialsMatcher.HASH_ALGORITHM_NAME, entity.getApiSecret(), salt, securityConfig.getShiroNbHashIterations()).toBase64();
transactionalSqlDao.execute(false, new EntitySqlDaoTransactionWrapper<Void>() {
@Override
public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
final TenantModelDao tenantModelDaoWithSecret = new TenantModelDao(entity.getId(), context.getCreatedDate(), context.getUpdatedDate(), entity.getExternalKey(), entity.getApiKey(), hashedPasswordBase64, salt.toBase64());
final TenantSqlDao tenantSqlDao = entitySqlDaoWrapperFactory.become(TenantSqlDao.class);
createAndRefresh(tenantSqlDao, tenantModelDaoWithSecret, context);
return null;
}
});
}
use of org.killbill.billing.util.entity.dao.EntitySqlDaoWrapperFactory in project killbill by killbill.
the class DefaultAuditDao method doGetAuditLogsViaHistoryForId.
private List<AuditLog> doGetAuditLogsViaHistoryForId(final TableName tableName, final UUID objectId, final AuditLevel auditLevel, final InternalTenantContext context) {
final TableName historyTableName = tableName.getHistoryTableName();
if (historyTableName == null) {
throw new IllegalStateException("History table shouldn't be null for " + tableName);
}
final Long targetRecordId = dbRouter.onDemand(true).getRecordIdFromObject(objectId.toString(), tableName.getTableName());
final List<AuditLog> allAuditLogs = transactionalSqlDao.execute(true, new EntitySqlDaoTransactionWrapper<List<AuditLog>>() {
@Override
public List<AuditLog> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception {
final List<AuditLogModelDao> auditLogsViaHistoryForTargetRecordId = entitySqlDaoWrapperFactory.become(EntitySqlDao.class).getAuditLogsViaHistoryForTargetRecordId(historyTableName.name(), historyTableName.getTableName().toLowerCase(), targetRecordId, context);
return buildAuditLogsFromModelDao(auditLogsViaHistoryForTargetRecordId, tableName.getObjectType(), objectId);
}
});
return filterAuditLogs(auditLevel, allAuditLogs);
}
Aggregations