Search in sources :

Example 11 with KerberosConfig

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);
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) CreateKerberosConfigRequest(com.sequenceiq.freeipa.api.v1.kerberos.model.create.CreateKerberosConfigRequest) Test(org.junit.jupiter.api.Test)

Example 12 with 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);
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) Test(org.junit.jupiter.api.Test)

Example 13 with KerberosConfig

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;
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Example 14 with KerberosConfig

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;
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig)

Example 15 with KerberosConfig

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);
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig)

Aggregations

KerberosConfig (com.sequenceiq.freeipa.kerberos.KerberosConfig)18 Test (org.junit.jupiter.api.Test)8 CreateKerberosConfigRequest (com.sequenceiq.freeipa.api.v1.kerberos.model.create.CreateKerberosConfigRequest)5 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)4 Stack (com.sequenceiq.freeipa.entity.Stack)4 ActiveDirectoryKerberosDescriptor (com.sequenceiq.freeipa.api.v1.kerberos.model.create.ActiveDirectoryKerberosDescriptor)2 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)2 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)2 CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)2 KerberosConfigService (com.sequenceiq.freeipa.kerberos.KerberosConfigService)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Service (org.springframework.stereotype.Service)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)1