Search in sources :

Example 1 with IcInvalidCredentialException

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);
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) ResponseEntity(org.springframework.http.ResponseEntity) IcConfigurationService(eu.bcvsolutions.idm.ic.service.api.IcConfigurationService) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with IcInvalidCredentialException

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;
}
Also used : ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcInvalidCredentialException(eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException) InvalidCredentialException(org.identityconnectors.framework.common.exceptions.InvalidCredentialException) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) IcServerNotFoundException(eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorInfoManager(org.identityconnectors.framework.api.ConnectorInfoManager) IcCantConnectException(eu.bcvsolutions.idm.ic.exception.IcCantConnectException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) RemoteFrameworkConnectionInfo(org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)

Aggregations

IcCantConnectException (eu.bcvsolutions.idm.ic.exception.IcCantConnectException)2 IcInvalidCredentialException (eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException)2 IcRemoteServerException (eu.bcvsolutions.idm.ic.exception.IcRemoteServerException)2 IcServerNotFoundException (eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException)2 SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 IcConfigurationService (eu.bcvsolutions.idm.ic.service.api.IcConfigurationService)1 ApiOperation (io.swagger.annotations.ApiOperation)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 ConnectorInfoManager (org.identityconnectors.framework.api.ConnectorInfoManager)1 RemoteFrameworkConnectionInfo (org.identityconnectors.framework.api.RemoteFrameworkConnectionInfo)1 ConnectorException (org.identityconnectors.framework.common.exceptions.ConnectorException)1 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)1 InvalidCredentialException (org.identityconnectors.framework.common.exceptions.InvalidCredentialException)1 ResponseEntity (org.springframework.http.ResponseEntity)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1