use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
// system
SysSystemDto system = new SysSystemDto();
String systemName = "t_s_" + System.currentTimeMillis();
system.setName(systemName);
system = systemService.save(system);
// system entity
SysSystemEntityDto systemEntity = new SysSystemEntityDto();
systemEntity.setSystem(system.getId());
systemEntity.setEntityType(SystemEntityType.IDENTITY);
String uid = "se_uid_" + System.currentTimeMillis();
systemEntity.setUid(uid);
systemEntity = systemEntityService.save(systemEntity);
// account
AccAccountDto account = new AccAccountDto();
account.setSystem(system.getId());
account.setUid("test_uid_" + System.currentTimeMillis());
account.setAccountType(AccountType.PERSONAL);
account.setSystemEntity(systemEntity.getId());
account = accountService.save(account);
SysSystemEntityDto systemEntityDto = DtoUtils.getEmbedded(account, AccAccount_.systemEntity, SysSystemEntityDto.class);
assertEquals(uid, systemEntityDto.getUid());
systemEntityService.delete(systemEntity);
assertNull(accountService.get(account.getId()).getSystemEntity());
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class ProvisioningStartProcessor method process.
@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
AccAccountDto account = event.getContent();
Assert.notNull(account);
LOG.info("Provisioning event start, for account id: [{}], account uid: [{}], real uid [{}] , system id: [{}]", account.getId(), account.getUid(), account.getRealUid(), account.getSystem());
if (account.isInProtection()) {
if (!isCanceledProvisioningProtectionBreak(event.getProperties())) {
LOG.info("Account [{}] is in protection. Provisioning is skipped.", account.getUid());
return new DefaultEventResult<>(event, this);
}
LOG.info("Account [{}] is in protection, but cancel attribute is TRUE. Provisioning is not skipped.", account.getUid());
}
provisioningService.doInternalProvisioning(account, (AbstractDto) event.getProperties().get(ProvisioningService.DTO_PROPERTY_NAME));
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class AccAccountController method validateDto.
@Override
protected AccAccountDto validateDto(AccAccountDto dto) {
dto = super.validateDto(dto);
// preset entity type
if (dto.getSystemEntity() != null) {
SysSystemEntityDto systemEntity = systemEntityService.get(dto.getSystemEntity());
dto.setEntityType(systemEntity.getEntityType());
}
if (!getService().isNew(dto)) {
AccAccountDto previous = getDto(dto.getId());
if (previous.isInProtection() && !dto.isInProtection()) {
throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_UPDATE_IS_PROTECTED, ImmutableMap.of("uid", dto.getUid()));
}
}
return dto;
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testReferentialIntegrityAccountExists.
@Test(expected = ResultCodeException.class)
public void testReferentialIntegrityAccountExists() {
SysSystemDto system = new SysSystemDto();
String systemName = "t_s_" + System.currentTimeMillis();
system.setName(systemName);
system = systemService.save(system);
// account
AccAccountDto account = new AccAccountDto();
account.setSystem(system.getId());
account.setUid("test_uid_" + System.currentTimeMillis());
account.setAccountType(AccountType.PERSONAL);
account = accountService.save(account);
systemService.delete(system);
}
use of eu.bcvsolutions.idm.acc.dto.AccAccountDto in project CzechIdMng by bcvsolutions.
the class PasswordPreValidationIntegrationTest method testMinChar.
@Test
public void testMinChar() {
IdmIdentityDto identity = new IdmIdentityDto();
identity.setUsername("test" + System.currentTimeMillis());
identity.setFirstName("testFirst");
identity.setLastName("testSecond");
identity = idmIdentityService.save(identity);
//
SysSystemDto system = testHelper.createTestResourceSystem(true);
//
AccAccountDto acc = new AccAccountDto();
acc.setId(UUID.randomUUID());
acc.setUid(System.currentTimeMillis() + "");
acc.setAccountType(AccountType.PERSONAL);
acc.setSystem(system.getId());
//
acc = accountService.save(acc);
//
AccIdentityAccountDto account = testHelper.createIdentityAccount(system, identity);
account.setAccount(acc.getId());
account = accountIdentityService.save(account);
account.setOwnership(true);
List<String> accounts = new ArrayList<String>();
accounts.add(acc.getId() + "");
// password policy default
IdmPasswordPolicyDto policyDefault = new IdmPasswordPolicyDto();
policyDefault.setName(System.currentTimeMillis() + "test1");
policyDefault.setDefaultPolicy(true);
policyDefault.setMinUpperChar(6);
policyDefault.setMinLowerChar(10);
// password policy
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(System.currentTimeMillis() + "test2");
policy.setDefaultPolicy(false);
policy.setMinUpperChar(5);
policy.setMinLowerChar(11);
policyDefault = passwordPolicyService.save(policyDefault);
policy = passwordPolicyService.save(policy);
system.setPasswordPolicyValidate(policy.getId());
systemService.save(system);
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setIdm(true);
passwordChange.setAccounts(accounts);
passwordChange.setAll(true);
try {
idmIdentityService.validatePassword(passwordChange);
} catch (ResultCodeException ex) {
assertEquals(6, ex.getError().getError().getParameters().get("minUpperChar"));
assertEquals(11, ex.getError().getError().getParameters().get("minLowerChar"));
assertEquals(policy.getName() + ", " + policyDefault.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
assertEquals(3, ex.getError().getError().getParameters().size());
policyDefault.setDefaultPolicy(false);
passwordPolicyService.save(policyDefault);
}
}
Aggregations