use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class GatewayTopologyToGatewayTopologyV4ResponseConverter method convert.
public GatewayTopologyV4Response convert(GatewayTopology source) {
GatewayTopologyV4Response response = new GatewayTopologyV4Response();
ExposedServices exposedServices = getExposedServices(source);
if (exposedServices != null) {
response.setExposedServices(exposedServices.getServices());
}
response.setTopologyName(source.getTopologyName());
return response;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class GatewayTopologyV4RequestToExposedServicesConverter method convert.
public ExposedServices convert(GatewayTopologyV4Request source) {
List<String> exposedServiceList = source.getExposedServices();
ExposedServices exposedServices = new ExposedServices();
if (!CollectionUtils.isEmpty(exposedServiceList)) {
ValidationResult validationResult = exposedServiceListValidator.validate(exposedServiceList);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
exposedServices.setServices(new ArrayList<>(exposedServiceList));
}
return exposedServices;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method mapTopologyToMap.
private Map<String, Object> mapTopologyToMap(GatewayTopology gt, Optional<String> version) throws IOException {
Map<String, Object> topology = new HashMap<>();
topology.put("name", gt.getTopologyName());
Json exposedJson = gt.getExposedServices();
if (exposedJson != null && isNotEmpty(exposedJson.getValue())) {
ExposedServices exposedServicesDomain = exposedJson.get(ExposedServices.class);
Set<String> exposedServices = exposedServiceCollector.getFullServiceListBasedOnList(exposedServicesDomain.getServices(), version);
topology.put("exposed", exposedServices);
} else {
topology.put("exposed", new HashSet<>());
}
return topology;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices in project cloudbreak by hortonworks.
the class KnoxGatewayConfigProviderTest method roleConfigsWithGatewayWhenOdbcEntitlementFalse.
@Test
public void roleConfigsWithGatewayWhenOdbcEntitlementFalse() {
GatewayTopology topology = new GatewayTopology();
topology.setTopologyName("my-topology");
topology.setExposedServices(Json.silent(new ExposedServices()));
Gateway gateway = new Gateway();
gateway.setKnoxMasterSecret("admin");
gateway.setPath("/a/b/c");
gateway.setTopologies(Set.of(topology));
IdBroker idBroker = new IdBroker();
idBroker.setMasterSecret("supersecret");
BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
generalClusterConfigs.setAccountId(Optional.of("1234"));
TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("");
when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(false);
assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", gateway.getTopologies().iterator().next().getTopologyName()), config("gateway_knox_admin_groups", ""), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_token_generation_enable_lifespan_input", "true"), config("gateway_token_generation_knox_token_ttl", "86400000"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Aggregations