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;
}
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));
}
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);
}
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);
}
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);
}
Aggregations