@Configuration
public class FilterRegistrationConfig {
- @Value("${runtime-ui.policy.mapping-path}")
+ @Value("${runtime-ui.policy-api.mapping-path}")
private String policyApiMappingPath;
+ @Value("${runtime-ui.policy-pap.mapping-path}")
+ private String policyPapMappingPath;
+
@Value("${runtime-ui.acm.mapping-path}")
private String acmRuntimeMappingPath;
registrationBean.setFilter(new ClientSslHeaderFilter());
registrationBean.addUrlPatterns(
StringUtils.stripEnd(policyApiMappingPath, "/") + "/*",
+ StringUtils.stripEnd(policyPapMappingPath, "/") + "/*",
StringUtils.stripEnd(acmRuntimeMappingPath, "/") + "/*"
);
return registrationBean;
* @param disableSslValidation Turn off SSL altogether on this REST interface
* @param disableSslHostnameCheck Turn off SSL host name checking
*/
- @Value("{runtime-ui.policy}")
+ @Value("{runtime-ui.policy-api}")
public void setSslFlags(
- @Value("${runtime-ui.policy.disable-ssl-validation:false}") boolean disableSslValidation,
- @Value("${runtime-ui.policy.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
+ @Value("${runtime-ui.policy-api.disable-ssl-validation:false}") boolean disableSslValidation,
+ @Value("${runtime-ui.policy-api.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
super.setDisableSslValidation(disableSslValidation);
super.setDisableSslHostnameCheck(disableSslHostnameCheck);
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.config;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class PolicyPapRestTemplateConfig extends BaseRestTemplateConfig {
+
+ /**
+ * Set the SSL validation flags on the template.
+ *
+ * @param disableSslValidation Turn off SSL altogether on this REST interface
+ * @param disableSslHostnameCheck Turn off SSL host name checking
+ */
+ @Value("{runtime-ui.policy-pap}")
+ public void setSslFlags(
+ @Value("${runtime-ui.policy-pap.disable-ssl-validation:false}") boolean disableSslValidation,
+ @Value("${runtime-ui.policy-pap.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
+ super.setDisableSslValidation(disableSslValidation);
+ super.setDisableSslHostnameCheck(disableSslHostnameCheck);
+ }
+
+ /**
+ * Returns a RestTemplate, optionally disabling SSL host name check or disabling SSL validation entirely.
+ */
+ @Bean
+ public RestTemplate policyPapRestTemplate() throws GeneralSecurityException, IOException {
+ return super.getRestTemplate();
+ }
+}
import org.springframework.web.client.RestTemplate;
@RestController
-@RequestMapping("${runtime-ui.policy.mapping-path}")
+@RequestMapping("${runtime-ui.policy-api.mapping-path}")
public class PolicyApiRestController extends BaseRestController {
/**
* Set the mapping parameters for the REST controller.
* @param mappingPath The mapping path to map from
* @param url The URL path to map to
*/
- @Value("{runtime-ui.policy}")
+ @Value("{runtime-ui.policy-api}")
public void setSslFlags(
- @Value("${runtime-ui.policy.mapping-path}") String mappingPath,
- @Value("${runtime-ui.policy.url}") URI url) {
+ @Value("${runtime-ui.policy-api.mapping-path}") String mappingPath,
+ @Value("${runtime-ui.policy-api.url}") URI url) {
super.setMappingPath(mappingPath);
super.setUrl(url);
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.rest;
+
+import java.net.URI;
+import javax.servlet.http.HttpServletRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+@RestController
+@RequestMapping("${runtime-ui.policy-pap.mapping-path}")
+public class PolicyPapRestController extends BaseRestController {
+ /**
+ * Set the mapping parameters for the REST controller.
+ *
+ * @param mappingPath The mapping path to map from
+ * @param url The URL path to map to
+ */
+ @Value("{runtime-ui.policy-pap}")
+ public void setSslFlags(
+ @Value("${runtime-ui.policy-pap.mapping-path}") String mappingPath,
+ @Value("${runtime-ui.policy-pap.url}") URI url) {
+ super.setMappingPath(mappingPath);
+ super.setUrl(url);
+ }
+
+ /**
+ * Set the REST template for the REST controller.
+ *
+ * @param restTemplate The REST template
+ */
+ @Autowired
+ public void setControllerRestTemplate(
+ @Qualifier("policyPapRestTemplate") RestTemplate restTemplate) {
+ super.setRestTemplate(restTemplate);
+ }
+
+ /**
+ * Proxy rest calls to ACM runtime.
+ */
+ @Override
+ @RequestMapping("/**")
+ public ResponseEntity<String> mirrorRest(@RequestBody(required = false) String body,
+ @RequestHeader HttpHeaders headers,
+ HttpMethod method,
+ HttpServletRequest request) {
+ return super.mirrorRest(body, headers, method, request);
+ }
+}
String[] args = {
"--server.port=0",
"--server.ssl.enabled=false",
- "--runtime-ui.policy.disable-ssl-validation=true",
- "--runtime-ui.policy.mapping-path=/policy-api",
- "--runtime-ui.policy.url=http://policyapi:9876/",
+ "--runtime-ui.policy-api.disable-ssl-validation=true",
+ "--runtime-ui.policy-api.mapping-path=/policy-api",
+ "--runtime-ui.policy-api.url=http://policyapi:9876/",
+ "--runtime-ui.policy-pap.disable-ssl-validation=true",
+ "--runtime-ui.policy-pap.mapping-path=/policy-pap",
+ "--runtime-ui.policy-pap.url=http://policypap:9876/",
"--runtime-ui.acm.disable-ssl-validation=true",
"--runtime-ui.acm.mapping-path=/acm-runtime",
"--runtime-ui.acm.url=http://acmruntime:9876/"
@SpringBootTest(
properties = {
- "runtime-ui.policy.disable-ssl-validation=true",
- "runtime-ui.policy.mapping-path=policy-api",
- "runtime-ui.policy.url=http://policyapi:9876/",
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-api.mapping-path=policy-api",
+ "runtime-ui.policy-api.url=http://policyapi:9876/",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.mapping-path=policy-pap",
+ "runtime-ui.policy-pap.url=http://policypap:9876/",
"runtime-ui.acm.disable-ssl-validation=true",
"runtime-ui.acm.mapping-path=acm-runtime",
"runtime-ui.acm.url=http://acmruntime:9876/"
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.gui.server.test.util;
+package org.onap.policy.gui.server.config;
import java.util.ArrayList;
import java.util.List;
@Qualifier("policyApiRestTemplate")
private RestTemplate policyApiRestTemplate;
+ @Autowired
+ @Qualifier("policyPapRestTemplate")
+ private RestTemplate policyPapRestTemplate;
+
@Getter
List<RestTemplate> restTemplateList = new ArrayList<>();
+ /**
+ * Add the REST templates for each REST interface.
+ */
@PostConstruct
public void setupRestTemplateList() {
restTemplateList.add(acmRuntimeRestTemplate);
restTemplateList.add(policyApiRestTemplate);
+ restTemplateList.add(policyPapRestTemplate);
}
}
import javax.net.ssl.SSLPeerUnverifiedException;
import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.client.RestClientException;
classes = {
HelloWorldApplication.class,
AcmRuntimeRestTemplateConfig.class,
- PolicyApiRestTemplateConfig.class
+ PolicyApiRestTemplateConfig.class,
+ PolicyPapRestTemplateConfig.class
},
properties = {
"server.ssl.enabled=true",
"server.ssl.trust-store-password=changeit",
"runtime-ui.acm.disable-ssl-validation=false",
"runtime-ui.acm.disable-ssl-hostname-check=false",
- "runtime-ui.policy.disable-ssl-validation=false",
- "runtime-ui.policy.disable-ssl-hostname-check=false"
+ "runtime-ui.policy-api.disable-ssl-validation=false",
+ "runtime-ui.policy-api.disable-ssl-hostname-check=false",
+ "runtime-ui.policy-pap.disable-ssl-validation=false",
+ "runtime-ui.policy-pap.disable-ssl-hostname-check=false"
},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RestTemplateConfig1Test {
import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
import org.springframework.boot.test.context.SpringBootTest;
HelloWorldApplication.class,
AcmRuntimeRestTemplateConfig.class,
PolicyApiRestTemplateConfig.class,
+ PolicyPapRestTemplateConfig.class
},
properties = {
"server.ssl.enabled=true",
"server.ssl.key-store=file:src/test/resources/helloworld-keystore.jks",
"server.ssl.key-store-password=changeit",
"runtime-ui.acm.disable-ssl-validation=true",
- "runtime-ui.policy.disable-ssl-validation=true"
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.disable-ssl-validation=true"
},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RestTemplateConfig2Test {
import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
import org.springframework.boot.test.context.SpringBootTest;
classes = {
HelloWorldApplication.class,
AcmRuntimeRestTemplateConfig.class,
- PolicyApiRestTemplateConfig.class
+ PolicyApiRestTemplateConfig.class,
+ PolicyPapRestTemplateConfig.class
},
properties = {
"server.ssl.enabled=true",
"server.ssl.trust-store-password=changeit",
"runtime-ui.acm.disable-ssl-validation=false",
"runtime-ui.acm.disable-ssl-hostname-check=true",
- "runtime-ui.policy.disable-ssl-validation=false",
- "runtime-ui.policy.disable-ssl-hostname-check=true"
+ "runtime-ui.policy-api.disable-ssl-validation=false",
+ "runtime-ui.policy-api.disable-ssl-hostname-check=true",
+ "runtime-ui.policy-pap.disable-ssl-validation=false",
+ "runtime-ui.policy-pap.disable-ssl-hostname-check=true"
},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RestTemplateConfig3Test {
import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
import org.springframework.boot.test.context.SpringBootTest;
classes = {
HelloWorldApplication.class,
AcmRuntimeRestTemplateConfig.class,
- PolicyApiRestTemplateConfig.class
+ PolicyApiRestTemplateConfig.class,
+ PolicyPapRestTemplateConfig.class
},
properties = {
"server.ssl.enabled=true",
"server.ssl.trust-store-password=changeit",
"runtime-ui.acm.disable-ssl-validation=true",
"runtime-ui.acm.disable-ssl-hostname-check=false",
- "runtime-ui.policy.disable-ssl-validation=true",
- "runtime-ui.policy.disable-ssl-hostname-check=false"
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-api.disable-ssl-hostname-check=false",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.disable-ssl-hostname-check=false"
},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RestTemplateConfig4Test {
import javax.net.ssl.SSLPeerUnverifiedException;
import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.client.RestClientException;
classes = {
HelloWorldApplication.class,
AcmRuntimeRestTemplateConfig.class,
- PolicyApiRestTemplateConfig.class
+ PolicyApiRestTemplateConfig.class,
+ PolicyPapRestTemplateConfig.class
},
properties = {
"server.ssl.enabled=true",
class RestTemplateTrustStoreUnsetTest {
BaseRestTemplateConfig[] restTemplateConfigArray = {
new AcmRuntimeRestTemplateConfig(),
- new PolicyApiRestTemplateConfig()
+ new PolicyApiRestTemplateConfig(),
+ new PolicyPapRestTemplateConfig()
};
@Test
@SpringBootTest(
properties = {
- "runtime-ui.policy.mapping-path=/runtime-ui/policy/restservices/",
- "runtime-ui.policy.url=http://policy-api:9876/",
- "runtime-ui.policy.disable-ssl-validation=true",
+ "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+ "runtime-ui.policy-api.url=http://policy-api:9876/",
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+ "runtime-ui.policy-pap.url=http://policy-pap:9876/",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
"runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
"runtime-ui.acm.url=https://runtime-acm:8443/",
"runtime-ui.acm.disable-ssl-validation=true"
@SpringBootTest(
properties = {
- "runtime-ui.policy.disable-ssl-validation=true",
- "runtime-ui.policy.mapping-path=policy-api",
- "runtime-ui.policy.url=http://policyapi:9876/",
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-api.mapping-path=policy-api",
+ "runtime-ui.policy-api.url=http://policyapi:9876/",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.mapping-path=policy-pap",
+ "runtime-ui.policy-pap.url=http://policypap:9876/",
"runtime-ui.acm.disable-ssl-validation=true",
"runtime-ui.acm.mapping-path=acm-runtime",
"runtime-ui.acm.url=http://acmruntime:9876/"
@SpringBootTest(
properties = {
- "runtime-ui.policy.mapping-path=/runtime-ui/policy/restservices/",
- "runtime-ui.policy.url=https://policy-api:9876/",
- "runtime-ui.policy.disable-ssl-validation=true",
+ "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+ "runtime-ui.policy-api.url=https://policy-api:9876/",
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+ "runtime-ui.policy-pap.url=https://policy-pap:9876/",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
"runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
"runtime-ui.acm.url=https://runtime-acm:8443/",
"runtime-ui.acm.disable-ssl-validation=true"
@Autowired
public void setBaseMapping(
- @Value("${runtime-ui.policy.mapping-path}") String mappingPath,
- @Value("${runtime-ui.policy.url}") URI url) {
+ @Value("${runtime-ui.policy-api.mapping-path}") String mappingPath,
+ @Value("${runtime-ui.policy-api.url}") URI url) {
super.setMappingPath(mappingPath);
super.setUrl(url);
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.rest;
+
+import java.net.URI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootTest(
+ properties = {
+ "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+ "runtime-ui.policy-api.url=https://policy-api:9876/",
+ "runtime-ui.policy-api.disable-ssl-validation=true",
+ "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+ "runtime-ui.policy-pap.url=https://policy-pap:9876/",
+ "runtime-ui.policy-pap.disable-ssl-validation=true",
+ "runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
+ "runtime-ui.acm.url=https://runtime-acm:8443/",
+ "runtime-ui.acm.disable-ssl-validation=true"
+ })
+@AutoConfigureMockMvc
+class PolicyPapRestControllerTest extends BaseRestControllerTest {
+ @Autowired
+ public void setBaseMockServer(@Qualifier("policyPapRestTemplate") RestTemplate restTemplate) {
+ super.setMockServer(MockRestServiceServer.createServer(restTemplate));
+ }
+
+ @Autowired
+ public void setBaseMapping(
+ @Value("${runtime-ui.policy-pap.mapping-path}") String mappingPath,
+ @Value("${runtime-ui.policy-pap.url}") URI url) {
+ super.setMappingPath(mappingPath);
+ super.setUrl(url);
+ }
+}
enabled: false
runtime-ui:
- policy:
- mapping-path: "/runtime-ui/policy/restservices"
+ policy-api:
+ mapping-path: "/runtime-ui/policy-api/restservices/"
url: http://localhost:30440
disable-ssl-validation: true
disable-ssl-hostname-check: true
+ policy-pap:
+ mapping-path: "/runtime-ui/policy-pap/restservices/"
+ url: http://localhost:30442
+ disable-ssl-validation: true
+ disable-ssl-hostname-check: true
+
acm:
- mapping-path: "/runtime-ui/acm/restservices"
+ mapping-path: "/runtime-ui/acm/restservices/"
url: http://localhost:30258
disable-ssl-validation: true
disable-ssl-hostname-check: true
trust-store-password: changeit
runtime-ui:
- policy:
- mapping-path: "/runtime-ui/policy/restservices"
+ policy-api:
+ mapping-path: "/runtime-ui/policy-api/restservices/"
url: http://localhost:30440
disable-ssl-validation: true
disable-ssl-hostname-check: true
+ policy-pap:
+ mapping-path: "/runtime-ui/policy-pap/restservices/"
+ url: http://localhost:30442
+ disable-ssl-validation: true
+ disable-ssl-hostname-check: true
+
acm:
- mapping-path: "/runtime-ui/acm/restservices"
+ mapping-path: "/runtime-ui/acm/restservices/"
url: http://localhost:30258
disable-ssl-validation: true
disable-ssl-hostname-check: true