use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityPasswordPreValidateDefinitionProcessor method process.
@Override
public EventResult<PasswordChangeDto> process(EntityEvent<PasswordChangeDto> event) {
PasswordChangeDto passwordChangeDto = event.getContent();
IdmPasswordValidationDto passwordValidationDto = new IdmPasswordValidationDto();
List<IdmPasswordPolicyDto> passwordPolicyList = validateDefinition(passwordChangeDto);
this.passwordPolicyService.preValidate(passwordValidationDto, passwordPolicyList);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityRoleDeleteAccountProcessor method process.
@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
IdmIdentityRoleDto identityRole = event.getContent();
accountManagementService.deleteIdentityAccount(identityRole);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityRoleDeleteProvisioningProcessor method process.
@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
IdmIdentityRoleDto identityRole = event.getContent();
IdmIdentityContractDto identityContract = identityContractService.get(identityRole.getIdentityContract());
IdmIdentityDto identity = DtoUtils.getEmbedded(identityContract, IdmIdentityContract_.identity, IdmIdentityDto.class);
LOG.debug("Call provisioning for identity [{}]", identity.getUsername());
provisioningService.doProvisioning(identity);
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestProvisioningProcessor method process.
@Override
public EventResult<IdmIdentityRoleValidRequestDto> process(EntityEvent<IdmIdentityRoleValidRequestDto> event) {
// IdentityRole and IdentityContract must exist - referential integrity.
//
// object identityRole is never null
UUID identityRoleId = event.getContent().getIdentityRole();
IdmIdentityRoleDto identityRole = identityRoleService.get(identityRoleId);
//
if (identityRole == null) {
LOG.warn("[IdentityRoleValidRequestProvisioningProcessor] Identity role isn't exists for identity role valid request id: [{}]", event.getContent().getId());
return new DefaultEventResult<>(event, this);
}
//
IdmIdentityContractDto identityContract = identityContractService.get(identityRole.getIdentityContract());
if (identityContract != null) {
LOG.info("[IdentityRoleValidRequestProvisioningProcessor] Start with provisioning for identity role valid request id : [{}]", event.getContent().getId());
//
IdmIdentityDto identity = DtoUtils.getEmbedded(identityContract, IdmIdentityContract_.identity, IdmIdentityDto.class);
boolean requiredProvisioning = getProvisioningService().accountManagement(identity);
if (requiredProvisioning) {
// do provisioning, for newly valid role
getProvisioningService().doProvisioning(identity);
}
//
} else {
LOG.warn("[IdentityRoleValidRequestProvisioningProcessor] Identity contract isn't exists for identity role valid request id: [{}]", event.getContent().getId());
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.event.DefaultEventResult in project CzechIdMng by bcvsolutions.
the class IdentitySetPasswordProcessor method process.
@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
IdmIdentityDto previousIdentity = event.getOriginalSource();
IdmIdentityDto newIdentity = event.getContent();
if (stateStarting(previousIdentity, newIdentity) && hasAccount(newIdentity)) {
// change password for all systems
PasswordChangeDto passwordChangeDto = new PasswordChangeDto();
//
// public password change password for all system including idm
passwordChangeDto.setAll(true);
passwordChangeDto.setIdm(true);
// TODO: how to generate password for all system policies
GuardedString password = new GuardedString(passwordPolicyService.generatePasswordByDefault());
passwordChangeDto.setNewPassword(password);
//
List<OperationResult> results = identityService.passwordChange(newIdentity, passwordChangeDto);
//
List<IdmAccountDto> successAccounts = new ArrayList<>();
List<OperationResult> failureResults = new ArrayList<>();
List<String> systemNames = new ArrayList<>();
results.forEach(result -> {
if (result.getModel() != null) {
boolean success = result.getModel().getStatusEnum().equals(CoreResultCode.PASSWORD_CHANGE_ACCOUNT_SUCCESS.name());
if (success) {
IdmAccountDto account = (IdmAccountDto) result.getModel().getParameters().get(IdmAccountDto.PARAMETER_NAME);
systemNames.add(account.getSystemName());
successAccounts.add(account);
} else {
// exception is logged before
failureResults.add(result);
}
}
});
// send notification if at least one system success
if (!successAccounts.isEmpty()) {
notificationManager.send(CoreModuleDescriptor.TOPIC_PASSWORD_CHANGED, new IdmMessageDto.Builder().setLevel(NotificationLevel.SUCCESS).addParameter("successSystemNames", StringUtils.join(systemNames, ", ")).addParameter("successAccounts", successAccounts).addParameter("failureResults", failureResults).addParameter("name", identityService.getNiceLabel(newIdentity)).addParameter("password", password).build(), newIdentity);
}
}
return new DefaultEventResult<>(event, this);
}
Aggregations