use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationController method cancel.
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_ADMIN + "')")
@RequestMapping(value = "/{backendId}/cancel", method = RequestMethod.PUT)
@ApiOperation(value = "Cancel provisioning operation", nickname = "cancelProvisioningOperation", response = SysProvisioningOperation.class, tags = { SysProvisioningOperationController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }) })
public ResponseEntity<?> cancel(@ApiParam(value = "Provisioning operation's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
SysProvisioningOperationDto provisioningOperation = getDto(backendId);
if (provisioningOperation == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
provisioningOperation = provisioningExecutor.cancel(provisioningOperation);
return new ResponseEntity<>(toResource(provisioningOperation), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationController method retry.
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_ADMIN + "')")
@RequestMapping(value = "/{backendId}/retry", method = RequestMethod.PUT)
@ApiOperation(value = "Retry provisioning operation", nickname = "retryProvisioningOperation", response = SysProvisioningOperation.class, tags = { SysProvisioningOperationController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }) })
public ResponseEntity<?> retry(@ApiParam(value = "Provisioning operation's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
SysProvisioningOperationDto provisioningOperation = getDto(backendId);
if (provisioningOperation == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
provisioningOperation = provisioningExecutor.executeSync(provisioningOperation);
return new ResponseEntity<>(toResource(provisioningOperation), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class IdentityAccountDeleteProcessor method process.
@Override
public EventResult<AccIdentityAccountDto> process(EntityEvent<AccIdentityAccountDto> event) {
AccIdentityAccountDto entity = event.getContent();
UUID account = entity.getAccount();
AccAccountDto accountDto = accountService.get(account);
Assert.notNull(accountDto, "Account cannot be null!");
// We check if exists another (ownership) identity-accounts, if not
// then we will delete account
List<AccIdentityAccountDto> identityAccounts = findIdentityAccounts(account);
boolean moreIdentityAccounts = identityAccounts.stream().filter(identityAccount -> {
return identityAccount.isOwnership() && !identityAccount.equals(entity);
}).findAny().isPresent();
boolean deleteTargetAccount = (boolean) event.getProperties().get(AccIdentityAccountService.DELETE_TARGET_ACCOUNT_KEY);
// If is account in protection, then we will not delete
// identity-account
// But is here exception from this. When is presented
// attribute FORCE_DELETE_OF_IDENTITY_ACCOUNT_KEY, then
// we will do delete of identity-account (it is important
// for integrity ... for example during delete of whole
// identity).
boolean forceDeleteIdentityAccount = isForceDeleteAttributePresent(event.getProperties());
if (!moreIdentityAccounts && entity.isOwnership()) {
if (accountDto.isAccountProtectedAndValid()) {
if (forceDeleteIdentityAccount) {
// Target account and AccAccount will deleted!
deleteTargetAccount = true;
} else {
throw new ResultCodeException(AccResultCode.ACCOUNT_CANNOT_BE_DELETED_IS_PROTECTED, ImmutableMap.of("uid", accountDto.getUid()));
}
// Is account protection activated on system mapping?
// Set account as protected we can only on account without protection (event has already invalid protection)!
} else if (!accountDto.isInProtection() && systemMappingService.isEnabledProtection(accountDto)) {
// This identity account is last ... protection will be
// activated
activateProtection(accountDto);
accountDto = accountService.save(accountDto);
entity.setRoleSystem(null);
entity.setIdentityRole(null);
service.save(entity);
doProvisioningSkipAccountProtection(accountDto, entity.getEntity());
// identity-account
if (forceDeleteIdentityAccount) {
// Target account and AccAccount will be deleted!
deleteTargetAccount = true;
} else {
return new DefaultEventResult<>(event, this);
}
}
}
service.deleteInternal(entity);
if (!moreIdentityAccounts && entity.isOwnership()) {
// We delete all identity accounts first
identityAccounts.stream().filter(identityAccount -> identityAccount.isOwnership() && !identityAccount.equals(entity)).forEach(identityAccount -> {
service.delete(identityAccount);
});
// Finally we can delete account
accountService.publish(new AccountEvent(AccountEventType.DELETE, accountDto, ImmutableMap.of(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY, deleteTargetAccount, AccAccountService.ENTITY_ID_PROPERTY, entity.getEntity())));
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class SysSystemController method getConnectorFormDefinition.
/**
* Returns connector form definition to given system
* or throws exception with code {@code CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND}, when system is wrong configured
*
* @param backendId
* @return
*/
@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_READ + "')")
@RequestMapping(value = "/{backendId}/connector-form-definition", method = RequestMethod.GET)
@ApiOperation(value = "Connector configuration - form definition", nickname = "getConnectorFormDefinition", tags = { SysSystemController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_READ, description = "") }) })
public ResponseEntity<?> getConnectorFormDefinition(@ApiParam(value = "System's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
SysSystemDto system = getDto(backendId);
if (system == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(system);
//
return new ResponseEntity<>(new Resource<>(formDefinition), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class SysSystemController method getConnectorFormDefinition.
/**
* Returns definition for given system
* or throws exception with code {@code CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND}, when system is wrong configured
*
* @param system
* @return
*/
private synchronized IdmFormDefinitionDto getConnectorFormDefinition(SysSystemDto system) {
Assert.notNull(system);
// connector key can't be null
if (system.getConnectorKey() == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_FORM_DEFINITION_NOT_FOUND, ImmutableMap.of("system", system.getId()));
}
// for remote connector form definition we need password for remote connector server
if (system.isRemote()) {
SysConnectorServerDto connectorServer = system.getConnectorServer();
connectorServer.setPassword(this.confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
system.setConnectorServer(connectorServer);
}
//
return systemService.getConnectorFormDefinition(system.getConnectorInstance());
}
Aggregations