Search in sources :

Example 1 with KerberosConfig

use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.

the class CreateKerberosConfigRequestToKerberosConfigConverter method convertMit.

private KerberosConfig convertMit(MITKerberosDescriptor source) {
    KerberosConfig config = new KerberosConfig();
    config.setAdminUrl(source.getAdminUrl());
    config.setRealm(source.getRealm());
    config.setUrl(source.getUrl());
    config.setPrincipal(source.getPrincipal());
    config.setType(source.getType());
    config.setDomain(source.getDomain());
    config.setNameServers(source.getNameServers());
    config.setPassword(source.getPassword());
    config.setVerifyKdcTrust(source.getVerifyKdcTrust());
    config.setTcpAllowed(source.getTcpAllowed());
    return config;
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig)

Example 2 with KerberosConfig

use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.

the class CreateKerberosConfigRequestToKerberosConfigConverter method convertActiveDirectory.

private KerberosConfig convertActiveDirectory(ActiveDirectoryKerberosDescriptor source) {
    KerberosConfig config = new KerberosConfig();
    config.setAdminUrl(source.getAdminUrl());
    config.setContainerDn(source.getContainerDn());
    config.setLdapUrl(source.getLdapUrl());
    config.setRealm(source.getRealm());
    config.setUrl(source.getUrl());
    config.setPrincipal(source.getPrincipal());
    config.setType(source.getType());
    config.setNameServers(source.getNameServers());
    config.setPassword(source.getPassword());
    config.setVerifyKdcTrust(source.getVerifyKdcTrust());
    config.setTcpAllowed(source.getTcpAllowed());
    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 3 with KerberosConfig

use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<CreateKerberosBindUserEvent> event) {
    CreateBindUserEvent data = event.getData();
    Optional<KerberosConfig> kerberosConfig = kerberosConfigService.find(data.getEnvironmentCrn(), data.getAccountId(), data.getSuffix());
    if (kerberosConfig.isPresent()) {
        LOGGER.info("Kerberos configuration already exist: {}", kerberosConfig.get());
        return new CreateBindUserEvent(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), data);
    } else {
        return createKerberosBindUser(event.getEvent(), data);
    }
}
Also used : KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)

Example 4 with KerberosConfig

use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.

the class KerberosConfigRegisterServiceTest method testRegister.

@Test
void testRegister() {
    Stack stack = new Stack();
    stack.setEnvironmentCrn("env");
    stack.setAccountId("acc");
    stack.setName("name");
    stack.setAppVersion("2.20.0");
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setDiscoveryFQDN("fqdn");
    instanceMetaData.setPrivateIp("1.1.1.1");
    instanceGroup.setInstanceMetaData(Collections.singleton(instanceMetaData));
    stack.setInstanceGroups(Collections.singleton(instanceGroup));
    when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain("testdomain.local");
    freeIpa.setAdminPassword("asdf");
    when(freeIpaService.findByStackId(anyLong())).thenReturn(freeIpa);
    when(balancedDnsAvailabilityChecker.isBalancedDnsAvailable(stack)).thenReturn(true);
    underTest.register(1L);
    ArgumentCaptor<KerberosConfig> kerberosConfigArgumentCaptor = ArgumentCaptor.forClass(KerberosConfig.class);
    ArgumentCaptor<String> accountIdArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(kerberosConfigService).createKerberosConfig(kerberosConfigArgumentCaptor.capture(), accountIdArgumentCaptor.capture());
    assertEquals(stack.getAccountId(), accountIdArgumentCaptor.getValue());
    KerberosConfig kerberosConfig = kerberosConfigArgumentCaptor.getValue();
    assertEquals(stack.getName(), kerberosConfig.getName());
    assertEquals(stack.getEnvironmentCrn(), kerberosConfig.getEnvironmentCrn());
    assertEquals("kdc.testdomain.local", kerberosConfig.getUrl());
    assertEquals("kerberos.testdomain.local", kerberosConfig.getAdminUrl());
    assertEquals(instanceMetaData.getPrivateIp(), kerberosConfig.getNameServers());
    assertEquals(freeIpa.getAdminPassword(), kerberosConfig.getPassword());
    assertEquals(freeIpa.getDomain(), kerberosConfig.getDomain());
    assertEquals(freeIpa.getDomain().toUpperCase(), kerberosConfig.getRealm());
    assertEquals(KerberosType.FREEIPA, kerberosConfig.getType());
    assertEquals(KerberosConfigRegisterService.FREEIPA_DEFAULT_ADMIN, kerberosConfig.getPrincipal());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 5 with KerberosConfig

use of com.sequenceiq.freeipa.kerberos.KerberosConfig in project cloudbreak by hortonworks.

the class KerberosConfigUpdateServiceTest method testUpdateNameservers.

@Test
void testUpdateNameservers() {
    Stack stack = new Stack();
    stack.setEnvironmentCrn("env");
    stack.setAccountId("acc");
    stack.setName("name");
    stack.setAppVersion("2.20.0");
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    InstanceMetaData instanceMetaData1 = new InstanceMetaData();
    instanceMetaData1.setDiscoveryFQDN("fqdn");
    instanceMetaData1.setPrivateIp("1.1.1.1");
    InstanceMetaData instanceMetaData2 = new InstanceMetaData();
    instanceMetaData2.setDiscoveryFQDN("fqdn");
    instanceMetaData2.setPrivateIp("2.2.2.2");
    instanceGroup.setInstanceMetaData(Set.of(instanceMetaData1, instanceMetaData2));
    stack.setInstanceGroups(Collections.singleton(instanceGroup));
    when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
    KerberosConfig kerberosConfig1 = mock(KerberosConfig.class);
    KerberosConfig kerberosConfig2 = mock(KerberosConfig.class);
    List<KerberosConfig> kerberosConfigs = List.of(kerberosConfig1, kerberosConfig2);
    when(kerberosConfigService.findAllInEnvironment(any())).thenReturn(kerberosConfigs);
    underTest.updateNameservers(1L);
    ArgumentCaptor<String> nameServersCaptor = ArgumentCaptor.forClass(String.class);
    verify(kerberosConfig1).setNameServers(nameServersCaptor.capture());
    verify(kerberosConfig2).setNameServers(nameServersCaptor.capture());
    List.of(nameServersCaptor.getValue(), nameServersCaptor.getValue()).forEach(actualNameServersValue -> {
        assertTrue("1.1.1.1,2.2.2.2".equals(actualNameServersValue) || "2.2.2.2,1.1.1.1".equals(actualNameServersValue));
    });
    verify(kerberosConfigService).saveAll(eq(kerberosConfigs));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) Test(org.junit.jupiter.api.Test)

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