use of eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException 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);
}
use of eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method findRemoteConnectorManager.
private ConnectorInfoManager findRemoteConnectorManager(IcConnectorServer server) {
// get all saved remote connector servers
RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(server.getHost(), server.getPort(), new org.identityconnectors.common.security.GuardedString(server.getPassword().asString().toCharArray()), server.isUseSsl(), null, server.getTimeout());
ConnectorInfoManager manager = null;
try {
// flush remote cache
ConnectorInfoManagerFactory.getInstance().clearRemoteCache();
manager = ConnectorInfoManagerFactory.getInstance().getRemoteManager(info);
} catch (InvalidCredentialException e) {
throw new IcInvalidCredentialException(server.getHost(), server.getPort(), e);
} catch (ConnectorIOException e) {
throw new IcServerNotFoundException(server.getHost(), server.getPort(), e);
} catch (ConnectorException e) {
throw new IcCantConnectException(server.getHost(), server.getPort(), e);
} catch (Exception e) {
throw new IcRemoteServerException(server.getHost(), server.getPort(), e);
}
return manager;
}
Aggregations