diff --git a/opensync-ext-cloud/pom.xml b/opensync-ext-cloud/pom.xml index 7ec3533..a35d90f 100644 --- a/opensync-ext-cloud/pom.xml +++ b/opensync-ext-cloud/pom.xml @@ -29,18 +29,6 @@ ${tip-wlan-cloud.release.version} - - - - - - - - - - - - customer-service-interface com.telecominfraproject.wlan diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java index a84698e..92d7ceb 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java @@ -86,7 +86,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra @PostConstruct private void postCreate() { LOG.info("Using Cloud integration"); - cloudEquipmentRecordCache = cacheManagerShortLived.getCache("KDC_equipment_record_cache"); + cloudEquipmentRecordCache = cacheManagerShortLived.getCache("equipment_record_cache"); opensyncNodeMap = Collections.synchronizedMap(new HashMap()); } diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudTemplatePostConfiguration.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudTemplatePostConfiguration.java deleted file mode 100644 index be10bf6..0000000 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudTemplatePostConfiguration.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.telecominfraproject.wlan.opensync.external.integration.client; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.client.AsyncRestTemplate; -import org.springframework.web.client.RestTemplate; - -import com.telecominfraproject.wlan.core.model.json.BaseJsonModel; - -/** - * @author dtop - * Configure rest client to understand KDC classes that are children of KDC BaseJsonModel - */ -@Configuration -@ConditionalOnClass(RestTemplate.class) -public class OpensyncCloudTemplatePostConfiguration { - - private static final Logger LOG = LoggerFactory - .getLogger(OpensyncCloudTemplatePostConfiguration.class); - - - public OpensyncCloudTemplatePostConfiguration(@Autowired(required=false) AsyncRestTemplate asyncRestTemplate, @Autowired RestTemplate restTemplate) { - registerModulesWithObjectMappers(restTemplate); - if(asyncRestTemplate!=null) { - registerModulesWithObjectMappers(asyncRestTemplate); - } - } - - public static void registerModulesWithObjectMappers(AsyncRestTemplate restT) { - //this is needed so that rest client can produce and consume JSON objects with (and without) _type property - for(@SuppressWarnings("rawtypes") HttpMessageConverter c: restT.getMessageConverters()){ - if(c instanceof MappingJackson2HttpMessageConverter){ - LOG.info("Configuring ObjectMapper on AsyncRestTemplate"); - BaseJsonModel.registerAllSubtypes(((MappingJackson2HttpMessageConverter)c).getObjectMapper()); - } - } - } - - public static void registerModulesWithObjectMappers(RestTemplate restT) { - //this is needed so that rest client can produce and consume JSON objects with (and without) _type property - for(@SuppressWarnings("rawtypes") HttpMessageConverter c: restT.getMessageConverters()){ - if(c instanceof MappingJackson2HttpMessageConverter){ - LOG.info("Configuring ObjectMapper on RestTemplate"); - BaseJsonModel.registerAllSubtypes(((MappingJackson2HttpMessageConverter)c).getObjectMapper()); - } - } - } - - -} diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebConfig.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebConfig.java deleted file mode 100644 index 97bcaff..0000000 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.telecominfraproject.wlan.opensync.external.integration.client; - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Configuration; -import org.springframework.format.FormatterRegistry; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -import com.telecominfraproject.wlan.core.model.json.BaseJsonModel; - - -/** - * @author dtoptygin - * - */ -@Configuration -//@EnableWebMvc - DTOP: do not use this, it will break mapping for index.html file -// see http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-auto-configuration -public class OpensyncCloudWebConfig extends WebMvcConfigurerAdapter { - - private static final Logger LOG = LoggerFactory.getLogger(OpensyncCloudWebConfig.class); - - @Override - public void extendMessageConverters(List> converters) { - //this is needed so that servlets can consume and produce JSON objects with (and without) _type parameters - LOG.info("extending MessageConverters to understand KDC BaseJsonModel and its descendants"); - for(HttpMessageConverter c: converters){ - if(c instanceof MappingJackson2HttpMessageConverter){ - BaseJsonModel.registerAllSubtypes(((MappingJackson2HttpMessageConverter)c).getObjectMapper()); - } - } - } - - @Override - public void addFormatters(FormatterRegistry registry) { - // This is needed so that @RequestParam annotations in the servlet - // methods can be used with BaseJsonModel and its descendants and its - // collections. - - //Use GenericlConverter here, simple one does not work - LOG.info("Adding custom converters to process KDC BaseJsonModel and its descendants"); - - registry.addConverter(new OpensyncCloudWebGenericConverter()); - } - -} diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebGenericConverter.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebGenericConverter.java deleted file mode 100644 index 90b5819..0000000 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/client/OpensyncCloudWebGenericConverter.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.telecominfraproject.wlan.opensync.external.integration.client; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.convert.TypeDescriptor; -import org.springframework.core.convert.converter.GenericConverter; - -import com.telecominfraproject.wlan.core.model.json.BaseJsonModel; - -/** - * @author dtoptygin - * - */ -public class OpensyncCloudWebGenericConverter implements GenericConverter { - private static final Logger LOG = LoggerFactory.getLogger(OpensyncCloudWebGenericConverter.class); - private Set convertiblePairs; - - /** - * Format the typeDescriptor for logging - * @param typeDescriptor - * @return - */ - public static String getDataType(TypeDescriptor typeDescriptor) { - if (typeDescriptor == null) { - return ""; - } - if (typeDescriptor.isCollection()) { - return typeDescriptor.getName() + "<" + getDataType(typeDescriptor.getElementTypeDescriptor()) + ">"; - } - if (typeDescriptor.isArray()) { - return getDataType(typeDescriptor.getElementTypeDescriptor()) + "[]"; - } - return typeDescriptor.getName(); - } - - /** - * Constructor - */ - public OpensyncCloudWebGenericConverter() { - LOG.info("Registering Object Converter for the KDC models"); - convertiblePairs = new HashSet<>(); - convertiblePairs.add(new ConvertiblePair(String.class, BaseJsonModel.class)); - convertiblePairs.add(new ConvertiblePair(String.class, List.class)); - convertiblePairs.add(new ConvertiblePair(String.class, Set.class)); - } - - @Override - public Set getConvertibleTypes() { - return convertiblePairs; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - // dtop: this is ugly and needs to be generalized, but it works for - // List/Set of Integer/Long/BaseJsonModel/String - if (LOG.isTraceEnabled()) { - LOG.trace("Attempting to convert '{}' from {} to {}", source, getDataType(sourceType), - getDataType(targetType)); - } - - if (targetType.isAssignableTo(TypeDescriptor.valueOf(String.class)) || targetType - .isAssignableTo(TypeDescriptor.collection(Collection.class, TypeDescriptor.valueOf(String.class)))) { - LOG.trace("Proceeding with conversion of String ... "); - Object ret = null; - if (targetType.isCollection()) { - if (targetType.getName().equals(List.class.getName())) { - ret = new ArrayList(); - } else if (targetType.getName().equals(Set.class.getName())) { - ret = new HashSet(); - } else { - throw new IllegalStateException("Unsupported collection type " + targetType.getName()); - } - - if (sourceType.isArray() || sourceType.isCollection()) { - for (Object obj : (Iterable) source) { - ((Collection) ret).add((String) obj); - } - } else { - for (String str : ((String) source).split(",")) { - str = str.trim(); - if (str.isEmpty()) { - continue; - } - ((Collection) ret).add(str); - } - } - } - - return ret; - } - - if (targetType.isAssignableTo(TypeDescriptor.valueOf(Integer.class)) || targetType - .isAssignableTo(TypeDescriptor.collection(Collection.class, TypeDescriptor.valueOf(Integer.class)))) { - LOG.trace("Proceeding with conversion of Integer ... "); - Object ret = null; - if (targetType.isCollection()) { - if (targetType.getName().equals(List.class.getName())) { - ret = new ArrayList(); - } else if (targetType.getName().equals(Set.class.getName())) { - ret = new HashSet(); - } else { - throw new IllegalStateException("Unsupported collection type " + targetType.getName()); - } - - if (sourceType.isArray() || sourceType.isCollection()) { - for (Object obj : (Iterable) source) { - ((Collection) ret).add(Integer.parseInt((String) obj)); - } - } else { - for (String str : ((String) source).split(",")) { - str = str.trim(); - if (str.isEmpty()) { - continue; - } - ((Collection) ret).add(Integer.parseInt(str)); - } - } - } - - return ret; - } - - if (targetType.isAssignableTo(TypeDescriptor.valueOf(Long.class)) || targetType - .isAssignableTo(TypeDescriptor.collection(Collection.class, TypeDescriptor.valueOf(Long.class)))) { - LOG.trace("Proceeding with conversion of Long ... "); - Object ret = null; - if (targetType.isCollection()) { - if (targetType.getName().equals(List.class.getName())) { - ret = new ArrayList(); - } else if (targetType.getName().equals(Set.class.getName())) { - ret = new HashSet(); - } else { - throw new IllegalStateException("Unsupported collection type " + targetType.getName()); - } - - if (sourceType.isArray() || sourceType.isCollection()) { - for (Object obj : (Iterable) source) { - ((Collection) ret).add(Long.parseLong((String) obj)); - } - } else { - for (String str : ((String) source).split(",")) { - str = str.trim(); - if (str.isEmpty()) { - continue; - } - ((Collection) ret).add(Long.parseLong(str)); - } - } - } - - return ret; - } - - if (!targetType.isAssignableTo(TypeDescriptor.valueOf(BaseJsonModel.class)) && !targetType.isAssignableTo( - TypeDescriptor.collection(Collection.class, TypeDescriptor.valueOf(BaseJsonModel.class)))) { - throw new IllegalStateException( - "WC GenericConverter only handles BaseJsonModel and its collections and its descendants, not " - + targetType.getName()); - } - - LOG.trace("Proceeding with conversion of BaseJsonModel ... "); - - LOG.debug("Attempting to convert {} from {} to {}", source, sourceType.getName(), targetType.getName()); - - Object ret; - if (targetType.isCollection()) { - if (targetType.getName().equals(List.class.getName())) { - ret = new ArrayList(); - } else if (targetType.getName().equals(Set.class.getName())) { - ret = new HashSet(); - } else { - throw new IllegalStateException("Unsupported collection type " + targetType.getName()); - } - - if (sourceType.isArray() || sourceType.isCollection()) { - if (source != null) { - for (Object obj : (Iterable) source) { - ((Collection) ret).add(BaseJsonModel.fromString((String) obj, BaseJsonModel.class)); - } - } - } else { - if (source != null && !((String) source).isEmpty()) { - ((Collection) ret).addAll(BaseJsonModel.listFromString((String) source, BaseJsonModel.class)); - } - } - } else { - if (source != null && ((String) source).startsWith("[{")) { - // DT: should not ever get here - ret = BaseJsonModel.listFromString((String) source, BaseJsonModel.class); - } else { - if (source == null || "".equals(source)) { - return null; - } - ret = BaseJsonModel.fromString((String) source, BaseJsonModel.class); - } - } - - return ret; - } -} diff --git a/opensync-gateway-cloud-process/pom.xml b/opensync-gateway-cloud-process/pom.xml index b859ccf..438fb63 100644 --- a/opensync-gateway-cloud-process/pom.xml +++ b/opensync-gateway-cloud-process/pom.xml @@ -30,18 +30,6 @@ ${tip-wlan-cloud.release.version} - - webtoken-auth-service - com.telecominfraproject.wlan - ${tip-wlan-cloud.release.version} - - - - portal-services - com.telecominfraproject.wlan - ${tip-wlan-cloud.release.version} - - customer-service-remote com.telecominfraproject.wlan @@ -126,8 +114,6 @@ ${tip-wlan-cloud.release.version} - - diff --git a/opensync-gateway-cloud-process/src/main/java/com/telecominfraproject/wlan/opensync/experiment/OpenSyncGatewayCloudProcess.java b/opensync-gateway-cloud-process/src/main/java/com/telecominfraproject/wlan/opensync/experiment/OpenSyncGatewayCloudProcess.java index 8c2b402..970bc9a 100644 --- a/opensync-gateway-cloud-process/src/main/java/com/telecominfraproject/wlan/opensync/experiment/OpenSyncGatewayCloudProcess.java +++ b/opensync-gateway-cloud-process/src/main/java/com/telecominfraproject/wlan/opensync/experiment/OpenSyncGatewayCloudProcess.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; -@ComponentScan(basePackages={"com.telecominfraproject.wlan", "ai.connectus"}) +@ComponentScan(basePackages={"com.telecominfraproject.wlan"}) @EnableAutoConfiguration public class OpenSyncGatewayCloudProcess { diff --git a/opensync-gateway-cloud-process/src/main/resources/application.properties b/opensync-gateway-cloud-process/src/main/resources/application.properties index 15e931a..c6694f0 100644 --- a/opensync-gateway-cloud-process/src/main/resources/application.properties +++ b/opensync-gateway-cloud-process/src/main/resources/application.properties @@ -74,13 +74,11 @@ app.name=OpenSyncManager #spring.profiles.include=use_ssl,http_digest_auth,customer-credential-datastore-inmemory #spring.profiles.include=no_ssl,no_auth #spring.profiles.include=use_ssl,client_certificate_auth -spring.profiles.include=use_ssl,use_webtoken_auth,use_single_ds,RestTemplateConfiguration_X509_client_cert_auth,opensync_cloud_config -#use_ssl_with_client_cert_and_basic_auth,client_certificate_and_basic_auth,rest-template-single-user-per-service-digest-auth,use_single_ds,opensync_cloud_config +spring.profiles.include=use_ssl_with_client_cert_and_basic_auth,client_certificate_and_basic_auth,RestTemplateConfiguration_X509_client_cert_auth,use_single_ds,opensync_static_config + #used by *-remote client classes when they authenticate their requests tip.wlan.httpClientConfig=classpath:httpClientConfig.json -tip.wlan.introspectTokenApi.host=localhost:9091 -tip.wlan.introspectTokenApi.clientToken=token_placeholder #this user/password is used together with http_digest_auth and http_basic_auth spring profiles tip.wlan.serviceUser=user tip.wlan.servicePassword=password @@ -88,18 +86,28 @@ tip.wlan.servicePassword=password spring.main.show-banner=false server.port=9096 -#this port is used by secondary server connector, it is protected by digest authentication, while primary server.port is protected by client certificate auth +#this port is used by secondary server connector, it is protected by basic authentication, while primary server.port is protected by client certificate auth tip.wlan.secondaryPort=9097 #this server only supports REST requests, CSRF would get in the way tip.wlan.csrf-enabled=false #properties that configure remote interfaces to communicate with cloud -tip.wlan.cloudEventDispatcherBaseUrl=https://localhost:9031 -tip.wlan.customerServiceBaseUrl=https://localhost:9091 -tip.wlan.locationServiceBaseUrl=https://localhost:9091 -tip.wlan.equipmentServiceBaseUrl=https://localhost:9091 -tip.wlan.profileServiceBaseUrl=https://localhost:9091 +# when separate portal - prov - ssc processes are in use: +#tip.wlan.cloudEventDispatcherBaseUrl=https://localhost:9031 +#tip.wlan.customerServiceBaseUrl=https://localhost:9091 +#tip.wlan.locationServiceBaseUrl=https://localhost:9091 +#tip.wlan.equipmentServiceBaseUrl=https://localhost:9091 +#tip.wlan.profileServiceBaseUrl=https://localhost:9091 +#tip.wlan.routingServiceBaseUrl=https://localhost:9091 + +# For all-cloud-in-one-process : +tip.wlan.cloudEventDispatcherBaseUrl=https://localhost:9092 +tip.wlan.customerServiceBaseUrl=https://localhost:9092 +tip.wlan.locationServiceBaseUrl=https://localhost:9092 +tip.wlan.equipmentServiceBaseUrl=https://localhost:9092 +tip.wlan.profileServiceBaseUrl=https://localhost:9092 +tip.wlan.routingServiceBaseUrl=https://localhost:9092 #server.session-timeout= # session timeout in seconds