use of eu.bcvsolutions.idm.ic.service.api.IcConfigurationService 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());
//
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