Search in sources :

Example 11 with SysConnectorServerDto

use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.

the class SysRemoteServerControllerRestTest method prepareDto.

@Override
protected SysConnectorServerDto prepareDto() {
    SysConnectorServerDto dto = new SysConnectorServerDto();
    dto.setHost(getHelper().createName());
    dto.setPort(80);
    dto.setLocal(false);
    // 
    return dto;
}
Also used : SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)

Example 12 with SysConnectorServerDto

use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.

the class SysRemoteServerDtoLookupByExampleIntegrationTest method testFindByExample.

@Test
public void testFindByExample() {
    SysConnectorServerDto remoteServer = new SysConnectorServerDto();
    remoteServer.setHost("localhost");
    remoteServer.setPort(100);
    remoteServer.setTimeout(125);
    remoteServer.setUseSsl(true);
    SysConnectorServerDto remoteServerOne = remoteServerService.save(remoteServer);
    // 
    remoteServer = new SysConnectorServerDto();
    remoteServer.setHost("localhost");
    remoteServer.setPort(100);
    remoteServer.setTimeout(125);
    remoteServer.setUseSsl(false);
    SysConnectorServerDto remoteServerTwo = remoteServerService.save(remoteServer);
    // 
    SysConnectorServerDto example = new SysConnectorServerDto();
    example.setHost("localhost");
    example.setPort(100);
    example.setTimeout(125);
    example.setUseSsl(true);
    Assert.assertEquals(remoteServerOne, lookup.lookup(example));
    // 
    example.setUseSsl(false);
    Assert.assertEquals(remoteServerTwo, lookup.lookup(example));
    // 
    example.setTimeout(112);
    Assert.assertNull(lookup.lookup(example));
    // 
    example.setTimeout(125);
    example.setPort(444);
    Assert.assertNull(lookup.lookup(example));
    // 
    example.setPort(100);
    example.setHost("mock");
    Assert.assertNull(lookup.lookup(example));
}
Also used : SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 13 with SysConnectorServerDto

use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.

the class VsSystemServiceTest method testPasswordNotOverriden.

@Test
public /**
 * Test proves bug fix of password overriding trouble of the remote ConnectorServer.
 * This occurred when switching from VS system to remote ConnectorServer.
 */
void testPasswordNotOverriden() {
    final String testPassword = "myPassword123456";
    SysConnectorServerDto remoteServer = new SysConnectorServerDto();
    remoteServer.setHost(getHelper().createName());
    remoteServer.setPassword(new GuardedString(testPassword));
    remoteServer = remoteServerService.save(remoteServer);
    VsSystemDto config = new VsSystemDto();
    config.setName(helper.createName());
    SysSystemDto system = helper.createVirtualSystem(config);
    system.setRemoteServer(remoteServer.getId());
    system.setVirtual(false);
    system = systemService.save(system);
    String storedPassword = confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD).asString();
    Assert.assertEquals(testPassword, storedPassword);
}
Also used : SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) VsSystemDto(eu.bcvsolutions.idm.vs.dto.VsSystemDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 14 with SysConnectorServerDto

use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.

the class RemoteServerSaveProcessor method process.

@Override
public EventResult<SysConnectorServerDto> process(EntityEvent<SysConnectorServerDto> event) {
    SysConnectorServerDto dto = event.getContent();
    GuardedString password = dto.getPassword();
    SysConnectorServerDto remoteServer = service.saveInternal(dto);
    // save password from remote connector server to confidential storage
    if (password != null) {
        // save for newSystem
        confidentialStorage.save(remoteServer.getId(), SysRemoteServer.class, SysSystemService.REMOTE_SERVER_PASSWORD, password.asString());
        // 
        // set asterisks
        remoteServer.setPassword(new GuardedString(GuardedString.SECRED_PROXY_STRING));
    }
    // 
    // update all systems => we need to be backward compatible (see SysSystemDto.getConnectorInstance() + password is loaded direcly from confidential storage for systems)
    SysSystemFilter systemFilter = new SysSystemFilter();
    systemFilter.setRemoteServerId(remoteServer.getId());
    systemService.find(systemFilter, null).forEach(system -> {
        SysConnectorServerDto connectorServer = new SysConnectorServerDto(remoteServer);
        // usable password
        connectorServer.setPassword(password);
        // 
        system.setConnectorServer(connectorServer);
        systemService.save(system);
    });
    // 
    event.setContent(remoteServer);
    return new DefaultEventResult<>(event, this);
}
Also used : SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)

Example 15 with SysConnectorServerDto

use of eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto in project CzechIdMng by bcvsolutions.

the class RemoteServerDeleteProcessor method process.

@Override
public EventResult<SysConnectorServerDto> process(EntityEvent<SysConnectorServerDto> event) {
    SysConnectorServerDto remoteServer = event.getContent();
    UUID remoteServerId = remoteServer.getId();
    Assert.notNull(remoteServerId, "Remove server identifier is required.");
    // 
    // Check system not exists
    SysSystemFilter systemFilter = new SysSystemFilter();
    systemFilter.setRemoteServerId(remoteServerId);
    if (systemService.count(systemFilter) > 0) {
        throw new ResultCodeException(AccResultCode.REMOTE_SYSTEM_DELETE_FAILED_HAS_SYSTEMS, ImmutableMap.of("remoteServer", remoteServer.getFullServerName()));
    }
    // 
    // deletes all confidential values
    confidentialStorage.deleteAll(remoteServerId, SysRemoteServer.class);
    // 
    // deletes server
    service.deleteInternal(remoteServer);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) UUID(java.util.UUID)

Aggregations

SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)25 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 Test (org.junit.Test)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)7 SysSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter)6 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)6 UUID (java.util.UUID)6 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)5 IcCantConnectException (eu.bcvsolutions.idm.ic.exception.IcCantConnectException)5 IcInvalidCredentialException (eu.bcvsolutions.idm.ic.exception.IcInvalidCredentialException)5 IcRemoteServerException (eu.bcvsolutions.idm.ic.exception.IcRemoteServerException)5 IcServerNotFoundException (eu.bcvsolutions.idm.ic.exception.IcServerNotFoundException)5 IcConfigurationService (eu.bcvsolutions.idm.ic.service.api.IcConfigurationService)5 List (java.util.List)5 Set (java.util.Set)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 SysRemoteServerService (eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService)4 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)4 HashMap (java.util.HashMap)4