use of org.killbill.billing.tenant.api.TenantApiException in project killbill by killbill.
the class DefaultOverdueApi method uploadOverdueConfig.
@Override
public void uploadOverdueConfig(final String overdueXML, final CallContext callContext) throws OverdueApiException {
try {
final InternalTenantContext internalTenantContext = createInternalTenantContext(callContext);
final String tenantKey = TenantKey.OVERDUE_CONFIG.toString();
if (!tenantApi.getTenantValuesForKey(tenantKey, callContext).isEmpty()) {
tenantApi.deleteTenantKey(tenantKey, callContext);
}
tenantApi.addTenantKeyValue(tenantKey, overdueXML, callContext);
overdueConfigCache.clearOverdueConfig(internalTenantContext);
} catch (final TenantApiException e) {
throw new OverdueApiException(e);
}
}
use of org.killbill.billing.tenant.api.TenantApiException 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(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());
entitySqlDaoWrapperFactory.become(TenantSqlDao.class).create(tenantModelDaoWithSecret, context);
return null;
}
});
}
use of org.killbill.billing.tenant.api.TenantApiException in project killbill by killbill.
the class TestDefaultTenantUserApi method testCreateTenantWithExternalKeyOverLimit.
@Test(groups = "slow", description = "Test Tenant creation with External Key over limit")
public void testCreateTenantWithExternalKeyOverLimit() throws Exception {
final TenantData tenantdata = new DefaultTenant(UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,.", "TTR445ee2", "dskjhfs^^54R");
try {
tenantUserApi.createTenant(tenantdata, callContext);
Assert.fail();
} catch (final TenantApiException e) {
Assert.assertEquals(e.getCode(), ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED.getCode());
}
}
Aggregations