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