use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRemoteServerService method internalExport.
@Override
protected SysConnectorServerDto internalExport(UUID id) {
SysConnectorServerDto remoteServer = super.internalExport(id);
// Set remote connector server password to the null. We don't want update password on target IdM.
remoteServer.setPassword(null);
//
return remoteServer;
}
use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.
the class RemoteServerDeleteBulkAction method prevalidate.
@Override
public ResultModels prevalidate() {
IdmBulkActionDto action = getAction();
List<UUID> entities = getEntities(action, new StringBuilder());
ResultModels result = new ResultModels();
Map<ResultModel, Long> models = new HashMap<>();
entities.forEach(remoteServerId -> {
SysSystemFilter systemFilter = new SysSystemFilter();
systemFilter.setRemoteServerId(remoteServerId);
long count = systemService.count(systemFilter);
if (count > 0) {
SysConnectorServerDto remoteServer = getService().get(remoteServerId);
models.put(new DefaultResultModel(AccResultCode.REMOTE_SYSTEM_DELETE_FAILED_HAS_SYSTEMS, ImmutableMap.of("remoteServer", remoteServer.getFullServerName(), "count", count)), count);
}
});
//
// Sort by count
List<Entry<ResultModel, Long>> collect = models.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).collect(Collectors.toList());
collect.forEach(entry -> {
result.addInfo(entry.getKey());
});
//
return result;
}
use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.
the class DefaultConnectorServerConfiguration method getDefaultRemoteServer.
@Override
public SysConnectorServerDto getDefaultRemoteServer() {
UUID remoteServerId = getDefaultRemoteServerId();
if (remoteServerId == null) {
return null;
}
SysConnectorServerDto remoteServer = lookupService.lookupDto(SysConnectorServerDto.class, remoteServerId);
if (remoteServer == null) {
LOG.warn("Default remote server with identifier [{}] not found, returning null. Change configuration [{}]", remoteServerId, PROPERTY_DEFAULT_REMOTE_SERVER);
return null;
}
return remoteServer;
}
use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndImportRemoteSystem.
@Test
public void testExportAndImportRemoteSystem() {
SysConnectorServerDto connectorServer = new SysConnectorServerDto();
connectorServer.setHost(getHelper().createName());
connectorServer.setPort(43);
connectorServer.setPassword(new GuardedString("password"));
connectorServer = remoteServerService.save(connectorServer);
SysSystemDto system = createSystem();
system.setRemoteServer(connectorServer.getId());
system = systemService.save(system);
Assert.assertFalse(system.isDisabled());
// Make export, upload, delete system and import
executeExportAndImport(system, SystemExportBulkAction.NAME, ImmutableMap.of(EXECUTE_BEFORE_DTO_DELETE, this::deleteRemoteServer));
system = systemService.get(system.getId());
Assert.assertNotNull(system);
Assert.assertNotNull(system.getRemoteServer());
Assert.assertTrue(system.isDisabled());
Assert.assertNotNull(system.getConnectorServer());
Assert.assertNotNull(system.getConnectorServer().getHost());
// Password is not imported -> for new created system must be null!
Assert.assertNull(system.getConnectorServer().getPassword());
//
// get remote server
SysConnectorServerDto importedConnectorServer = remoteServerService.get(system.getRemoteServer());
Assert.assertEquals(connectorServer.getHost(), importedConnectorServer.getHost());
Assert.assertEquals(connectorServer.getPort(), importedConnectorServer.getPort());
Assert.assertEquals(connectorServer.isUseSsl(), importedConnectorServer.isUseSsl());
Assert.assertEquals(connectorServer.getTimeout(), importedConnectorServer.getTimeout());
// Password is not imported -> for new created remote server must be null!
Assert.assertTrue(remoteServerService.getPassword(importedConnectorServer.getId()).asString().isEmpty());
}
use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.
the class SysSystemController method getAvailableRemoteConnectors.
/**
* Rest endpoints return available remote connectors.
* If entity hasn't set for remote or isn't exists return empty map of connectors
*
* @param backendId
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "{backendId}/search/remote")
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_READ + "')")
@ApiOperation(value = "Get available remote connectors", nickname = "getAvailableRemoteConnectors", 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 = "") }) }, notes = "Supported remote conectors (by remote server configuration).")
public ResponseEntity<Map<String, Set<IcConnectorInfo>>> getAvailableRemoteConnectors(@ApiParam(value = "System's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
SysSystemDto dto = this.getDto(backendId);
Map<String, Set<IcConnectorInfo>> infos = new HashMap<>();
// if entity hasn't set up for remote return empty map
if (dto == null || !dto.isRemote()) {
return new ResponseEntity<Map<String, Set<IcConnectorInfo>>>(infos, HttpStatus.OK);
}
Assert.notNull(dto.getConnectorServer(), "Connector server is required.");
//
try {
for (IcConfigurationService config : icConfiguration.getIcConfigs().values()) {
SysConnectorServerDto server = dto.getConnectorServer();
server.setPassword(this.confidentialStorage.getGuardedString(dto.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
infos.put(config.getFramework(), config.getAvailableRemoteConnectors(server));
}
} catch (IcInvalidCredentialException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_INVALID_CREDENTIAL, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcServerNotFoundException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_NOT_FOUND, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcCantConnectException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_CANT_CONNECT, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
} catch (IcRemoteServerException e) {
throw new ResultCodeException(AccResultCode.REMOTE_SERVER_UNEXPECTED_ERROR, ImmutableMap.of("server", e.getHost() + ":" + e.getPort()), e);
}
//
return new ResponseEntity<Map<String, Set<IcConnectorInfo>>>(infos, HttpStatus.OK);
}
Aggregations