use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class CreateKerberosConfigRequestToKerberosConfigConverterTest method testMit.
@Test
public void testMit() {
CreateKerberosConfigRequest request = new CreateKerberosConfigRequest();
request.setMit(createMitKerberosDescriptor());
request.setName(NAME);
KerberosConfig kerberosConfig = underTest.convert(request);
checkMitParams(kerberosConfig);
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class KerberosBindUserCreationHandlerTest method testEventSentIfConfigAlreadyExists.
@Test
public void testEventSentIfConfigAlreadyExists() {
CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
HandlerEvent<CreateKerberosBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createKerberosBindUserEvent));
when(kerberosConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.of(new KerberosConfig()));
Selectable selectable = underTest.doAccept(handlerEvent);
assertTrue(selectable instanceof CreateBindUserEvent);
CreateBindUserEvent event = (CreateBindUserEvent) selectable;
assertEquals(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), event.selector());
assertEquals(createBindUserEvent.getOperationId(), event.getOperationId());
assertEquals(createBindUserEvent.getSuffix(), event.getSuffix());
assertEquals(createBindUserEvent.getAccountId(), event.getAccountId());
assertEquals(createBindUserEvent.getResourceId(), event.getResourceId());
verifyNoInteractions(stackService);
verifyNoInteractions(kerberosConfigV1Service);
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class CreateKerberosConfigRequestToKerberosConfigConverter method convert.
public KerberosConfig convert(CreateKerberosConfigRequest request) {
if (request == null || !KerberosRequestValidator.isValid(request)) {
throw new BadRequestException("Improper CreateKerberosConfigRequest!");
}
KerberosConfig kerberos;
if (request.getFreeIpa() != null) {
kerberos = convertFreeIpa(request.getFreeIpa());
} else if (request.getActiveDirectory() != null) {
kerberos = convertActiveDirectory(request.getActiveDirectory());
} else if (request.getMit() != null) {
kerberos = convertMit(request.getMit());
} else {
throw new BadRequestException("Unable to determine Kerberos Configuration since none of them are provided in the request!");
}
kerberos.setName(request.getName());
kerberos.setDescription(request.getDescription());
kerberos.setEnvironmentCrn(request.getEnvironmentCrn());
return kerberos;
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class CreateKerberosConfigRequestToKerberosConfigConverter method convertFreeIpa.
private KerberosConfig convertFreeIpa(FreeIpaKerberosDescriptor source) {
KerberosConfig config = new KerberosConfig();
config.setAdminUrl(source.getAdminUrl());
config.setRealm(source.getRealm());
config.setUrl(source.getUrl());
config.setType(source.getType());
config.setNameServers(source.getNameServers());
config.setPassword(source.getPassword());
config.setVerifyKdcTrust(source.getVerifyKdcTrust());
config.setTcpAllowed(source.getTcpAllowed());
config.setPrincipal(source.getPrincipal());
if (StringUtils.isNotBlank(source.getDomain())) {
config.setDomain(source.getDomain());
} else if (StringUtils.isNotBlank(source.getRealm())) {
config.setDomain(source.getRealm().toLowerCase());
}
return config;
}
use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.
the class KerberosConfigV1Service method post.
public DescribeKerberosConfigResponse post(CreateKerberosConfigRequest createKerberosConfigRequest) {
KerberosConfig kerberosConfig = createKerberosConfigRequestToKerberosConfigConverter.convert(createKerberosConfigRequest);
kerberosConfig = kerberosConfigService.createKerberosConfig(kerberosConfig);
return convertKerberosConfigToDescribeKerberosConfigResponse(kerberosConfig);
}
Aggregations