aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/rest-lib/src
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-26 09:49:13 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-03-26 09:49:13 -0400
commit72d22a4339db09824d46746dacbba1e141763dc0 (patch)
tree7fbfea4b81afca0bc0c95e5d4b810f236f4dea29 /ms/blueprintsprocessor/modules/commons/rest-lib/src
parentef6983b670796becfa66c69075c1829e8f9aef4b (diff)
Migrate ccdsk/apps to ccsdk/cds
Change-Id: I020a2ccec4e691717f888e8bd2afec91a7c4e987 Issue-ID: CCSDK-1178 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src')
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt39
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt55
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt58
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt129
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt115
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt29
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt72
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt47
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt35
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties16
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt58
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt83
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml35
13 files changed, 0 insertions, 771 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
deleted file mode 100644
index 7af91c6f..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest
-
-import org.springframework.boot.context.properties.EnableConfigurationProperties
-import org.springframework.context.annotation.ComponentScan
-import org.springframework.context.annotation.Configuration
-
-@Configuration
-@ComponentScan
-@EnableConfigurationProperties
-open class BluePrintRestLibConfiguration
-
-
-class RestLibConstants {
- companion object {
- const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
- const val TYPE_TOKEN_AUTH = "token-auth"
- const val TYPE_BASIC_AUTH = "basic-auth"
- const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
- const val TYPE_DME2_PROXY = "dme2-proxy"
- const val TYPE_POLICY_MANAGER = "policy-manager"
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
deleted file mode 100644
index dd4d9f7d..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest
-
-open class RestClientProperties {
- lateinit var type: String
- lateinit var url: String
-}
-
-open class BasicAuthRestClientProperties : RestClientProperties() {
- lateinit var password: String
- lateinit var username: String
-}
-
-open class TokenAuthRestClientProperties : RestClientProperties() {
- var token: String? = null
-}
-
-open class SSLBasicAuthRestClientProperties : RestClientProperties() {
- lateinit var keyStoreInstance: String // JKS, PKCS12
- lateinit var sslTrust: String
- lateinit var sslTrustPassword: String
- lateinit var sslKey: String
- lateinit var sslKeyPassword: String
-}
-
-open class DME2RestClientProperties : RestClientProperties() {
- lateinit var service: String
- lateinit var subContext: String
- lateinit var version: String
- lateinit var envContext: String
- lateinit var routeOffer: String
- var partner: String? = null
- lateinit var appId: String
-}
-
-open class PolicyManagerRestClientProperties : RestClientProperties() {
- lateinit var env: String
- lateinit var clientAuth: String
- lateinit var authorisation: String
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
deleted file mode 100644
index 98a4fd58..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T, Bell Canada, 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
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.apache.http.message.BasicHeader
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.springframework.http.HttpHeaders
-import org.springframework.http.MediaType
-import java.nio.charset.Charset
-import java.util.*
-
-class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) :
- BlueprintWebClientService {
-
- override fun defaultHeaders(): Map<String, String> {
- val encodedCredentials = setBasicAuth(restClientProperties.username, restClientProperties.password)
- return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials")
- }
-
- override fun host(uri: String): String {
- return restClientProperties.url + uri
- }
-
- override fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> {
- val customHeaders: MutableMap<String, String> = headers.toMutableMap()
- if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) {
- val encodedCredentials = setBasicAuth(restClientProperties.username, restClientProperties.password)
- customHeaders[HttpHeaders.AUTHORIZATION] = "Basic $encodedCredentials"
- }
- return super.convertToBasicHeaders(customHeaders)
- }
-
- private fun setBasicAuth(username: String, password: String): String {
- val credentialsString = "$username:$password"
- return Base64.getEncoder().encodeToString(credentialsString.toByteArray(Charset.defaultCharset()))
- }
-
-
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
deleted file mode 100644
index 3888bb72..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T, Bell Canada
- * Modifications Copyright © 2019 IBM.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.DME2RestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.PolicyManagerRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.springframework.stereotype.Service
-
-@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
-open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
-
- fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
- val restClientProperties = restClientProperties(jsonNode)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun blueprintWebClientService(selector: String): BlueprintWebClientService {
- val prefix = "blueprintsprocessor.restclient.$selector"
- val restClientProperties = restClientProperties(prefix)
- return blueprintWebClientService(restClientProperties)
- }
-
- fun restClientProperties(prefix: String): RestClientProperties {
- val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
- return when (type) {
- RestLibConstants.TYPE_BASIC_AUTH -> {
- basicAuthRestClientProperties(prefix)
- }
- RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
- sslBasicAuthRestClientProperties(prefix)
- }
- RestLibConstants.TYPE_DME2_PROXY -> {
- dme2ProxyClientProperties(prefix)
- }
- RestLibConstants.TYPE_POLICY_MANAGER -> {
- policyManagerRestClientProperties(prefix)
- }
- else -> {
- throw BluePrintProcessorException("Rest adaptor($type) is not supported")
- }
- }
- }
-
- private fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
- val type = jsonNode.get("type").textValue()
- return when (type) {
- RestLibConstants.TYPE_TOKEN_AUTH -> {
- JacksonUtils.readValue(jsonNode, TokenAuthRestClientProperties::class.java)!!
- }
- RestLibConstants.TYPE_BASIC_AUTH -> {
- JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
- }
- RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
- JacksonUtils.readValue(jsonNode, SSLBasicAuthRestClientProperties::class.java)!!
- }
- RestLibConstants.TYPE_DME2_PROXY -> {
- JacksonUtils.readValue(jsonNode, DME2RestClientProperties::class.java)!!
- }
- RestLibConstants.TYPE_POLICY_MANAGER -> {
- JacksonUtils.readValue(jsonNode, PolicyManagerRestClientProperties::class.java)!!
- }
- else -> {
- throw BluePrintProcessorException("Rest adaptor($type) is not supported")
- }
- }
- }
-
- private fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
- when (restClientProperties) {
- is TokenAuthRestClientProperties -> {
- return TokenAuthRestClientService(restClientProperties)
- }
- is BasicAuthRestClientProperties -> {
- return BasicAuthRestClientService(restClientProperties)
- }
- is SSLBasicAuthRestClientProperties -> {
- return SSLBasicAuthRestClientService(restClientProperties)
- }
- is DME2RestClientProperties -> {
- return DME2ProxyRestClientService(restClientProperties)
- }
- else -> {
- throw BluePrintProcessorException("couldn't get rest service for")
- }
- }
- }
-
- private fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
- return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
- }
-
- private fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
- return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
- }
-
- private fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
- return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
- }
-
- private fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
- return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
- }
-}
-
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
deleted file mode 100644
index 0629909e..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T, Bell Canada, 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
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.apache.commons.io.IOUtils
-import org.apache.http.client.methods.*
-import org.apache.http.entity.StringEntity
-import org.apache.http.impl.client.CloseableHttpClient
-import org.apache.http.impl.client.HttpClients
-import org.apache.http.message.BasicHeader
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.springframework.http.HttpMethod
-import java.nio.charset.Charset
-
-interface BlueprintWebClientService {
-
- fun defaultHeaders(): Map<String, String>
-
- fun host(uri: String): String
-
- fun httpClient(): CloseableHttpClient {
- return HttpClients.custom()
- .addInterceptorFirst(WebClientUtils.logRequest())
- .addInterceptorLast(WebClientUtils.logResponse())
- .build()
- }
-
- fun exchangeResource(methodType: String, path: String, request: String): String {
- return this.exchangeResource(methodType, path, request, defaultHeaders())
- }
-
- fun exchangeResource(methodType: String, path: String, request: String, headers: Map<String, String>): String {
- val convertedHeaders: Array<BasicHeader> = convertToBasicHeaders(headers)
- return when (HttpMethod.resolve(methodType)) {
- HttpMethod.DELETE -> delete(path, convertedHeaders)
- HttpMethod.GET -> get(path, convertedHeaders)
- HttpMethod.POST -> post(path, request, convertedHeaders)
- HttpMethod.PUT -> put(path, request, convertedHeaders)
- HttpMethod.PATCH -> patch(path, request, convertedHeaders)
- else -> throw BluePrintProcessorException("Unsupported methodType($methodType)")
- }
- }
-
- fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> {
- val convertedHeaders = Array<BasicHeader>(headers.size){ BasicHeader("","") }
- var currentElement = 0
- for ((name, value) in headers) {
- convertedHeaders[currentElement++] = BasicHeader(name, value)
- }
- return convertedHeaders
- }
-
- fun delete(path: String, headers: Array<BasicHeader>): String {
- val httpDelete = HttpDelete(host(path))
- httpDelete.setHeaders(headers)
- httpClient().execute(httpDelete).entity.content.use {
- return IOUtils.toString(it, Charset.defaultCharset())
- }
- }
-
- fun get(path: String, headers: Array<BasicHeader>): String {
- val httpGet = HttpGet(host(path))
- httpGet.setHeaders(headers)
- httpClient().execute(httpGet).entity.content.use {
- return IOUtils.toString(it, Charset.defaultCharset())
- }
- }
-
- fun post(path: String, request: String, headers: Array<BasicHeader>): String {
- val httpPost = HttpPost(host(path))
- val entity = StringEntity(request)
- httpPost.entity = entity
- httpPost.setHeaders(headers)
- httpClient().execute(httpPost).entity.content.use {
- return IOUtils.toString(it, Charset.defaultCharset())
- }
- }
-
- fun put(path: String, request: String, headers: Array<BasicHeader>): String {
- val httpPut = HttpPut(host(path))
- val entity = StringEntity(request)
- httpPut.entity = entity
- httpPut.setHeaders(headers)
- httpClient().execute(httpPut).entity.content.use {
- return IOUtils.toString(it, Charset.defaultCharset())
- }
- }
-
- fun patch(path: String, request: String, headers: Array<BasicHeader>): String {
- val httpPatch = HttpPatch(host(path))
- val entity = StringEntity(request)
- httpPatch.entity = entity
- httpPatch.setHeaders(headers)
- httpClient().execute(httpPatch).entity.content.use {
- return IOUtils.toString(it, Charset.defaultCharset())
- }
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
deleted file mode 100644
index 94e146d8..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T, Bell Canada
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
-
-class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
- override fun defaultHeaders(): Map<String, String> {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun host(uri: String): String {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
deleted file mode 100644
index 2bfacf41..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright © 2017-2019 AT&T, Bell Canada
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory
-import org.apache.http.impl.client.CloseableHttpClient
-import org.apache.http.impl.client.HttpClients
-import org.apache.http.ssl.SSLContextBuilder
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.utils.WebClientUtils
-import org.springframework.http.HttpHeaders
-import org.springframework.http.MediaType
-import java.io.File
-import java.io.FileInputStream
-import java.security.KeyStore
-import java.security.cert.X509Certificate
-
-class SSLBasicAuthRestClientService(private val restClientProperties: SSLBasicAuthRestClientProperties) :
- BlueprintWebClientService {
-
- override fun defaultHeaders(): Map<String, String> {
- return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE)
- }
-
- override fun host(uri: String): String {
- return restClientProperties.url + uri
- }
-
- override fun httpClient(): CloseableHttpClient {
-
- val keystoreInstance = restClientProperties.keyStoreInstance
- val sslKey = restClientProperties.sslKey
- val sslKeyPwd = restClientProperties.sslKeyPassword
- val sslTrust = restClientProperties.sslTrust
- val sslTrustPwd = restClientProperties.sslTrustPassword
-
- val acceptingTrustStrategy = { chain: Array<X509Certificate>, authType: String -> true }
-
- FileInputStream(sslKey).use { keyInput ->
- val keyStore = KeyStore.getInstance(keystoreInstance)
- keyStore.load(keyInput, sslKeyPwd.toCharArray())
-
- val sslContext =
- SSLContextBuilder.create()
- .loadKeyMaterial(keyStore, sslKeyPwd.toCharArray())
- .loadTrustMaterial(File(sslTrust), sslTrustPwd.toCharArray(), acceptingTrustStrategy).build()
-
- val csf = SSLConnectionSocketFactory(sslContext!!)
-
- return HttpClients.custom()
- .addInterceptorFirst(WebClientUtils.logRequest())
- .addInterceptorLast(WebClientUtils.logResponse())
- .setSSLSocketFactory(csf).build()
- }
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
deleted file mode 100644
index d5dec3ae..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright © 2019 Bell Canada, 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
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.apache.http.message.BasicHeader
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.TokenAuthRestClientProperties
-import org.springframework.http.HttpHeaders
-import org.springframework.http.MediaType
-
-class TokenAuthRestClientService(private val restClientProperties: TokenAuthRestClientProperties) :
- BlueprintWebClientService {
-
- override fun defaultHeaders(): Map<String, String> {
- return mapOf(
- HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE,
- HttpHeaders.AUTHORIZATION to restClientProperties.token!!)
- }
-
- override fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> {
- val customHeaders: MutableMap<String, String> = headers.toMutableMap()
- if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) {
- customHeaders[HttpHeaders.AUTHORIZATION] = restClientProperties.token!!
- }
- return super.convertToBasicHeaders(customHeaders)
- }
-
- override fun host(uri: String): String {
- return restClientProperties.url + uri
- }
-}
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
deleted file mode 100644
index b9a014e3..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/utils/WebClientUtils.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.utils
-
-import org.apache.http.HttpRequestInterceptor
-import org.apache.http.HttpResponseInterceptor
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-class WebClientUtils {
- companion object {
-
- val log: Logger = LoggerFactory.getLogger(WebClientUtils::class.java)
-
- fun logRequest(): HttpRequestInterceptor =
- HttpRequestInterceptor { request, _ -> log.info("Rest request method(${request?.requestLine?.method}), url(${request?.requestLine?.uri})") }
-
- fun logResponse(): HttpResponseInterceptor =
- HttpResponseInterceptor { response, _ -> log.info("Response status(${response.statusLine.statusCode} - ${response.statusLine.reasonPhrase})") }
- }
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
deleted file mode 100644
index 2ce87147..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright © 2017-2018 AT&T Intellectual Property.
-#
-# 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.
-#
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
deleted file mode 100644
index d6e5549a..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.TestPropertySource
-import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.assertNotNull
-
-
-@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
- "blueprintsprocessor.restclient.sample.userId=sampleuser"])
-
-class BluePrintRestLibPropertyServiceTest {
-
- @Autowired
- lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
-
- @Test
- fun testRestClientProperties() {
- val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample")
- assertNotNull(properties, "failed to create property bean")
- assertNotNull(properties.url, "failed to get url property in property bean")
- }
-
- @Test
- fun testBlueprintWebClientService() {
- val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
- assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
- }
-
-}
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
deleted file mode 100644
index 0390550c..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Copyright (C) 2019 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
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
-
-import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.http.HttpMethod
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.TestPropertySource
-import org.springframework.test.context.junit4.SpringRunner
-import org.springframework.web.bind.annotation.GetMapping
-import org.springframework.web.bind.annotation.PatchMapping
-import org.springframework.web.bind.annotation.RequestMapping
-import org.springframework.web.bind.annotation.RestController
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertNotNull
-
-@RunWith(SpringRunner::class)
-@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class,
- SampleController::class, BluePrintProperties::class, BluePrintProperties::class])
-@TestPropertySource(properties =
-["blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8080",
- "blueprintsprocessor.restclient.sample.username=sampleuser",
- "blueprintsprocessor.restclient.sample.password=sampletoken"])
-class RestClientServiceTest {
-
- @Autowired
- lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
-
- @Test
- fun testBaseAuth() {
- val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
- val headers = mutableMapOf<String, String>()
- headers["X-Transaction-Id"] = "1234"
- val response = restClientService.exchangeResource(HttpMethod.GET.name, "/sample/name", "")
- assertNotNull(response, "failed to get response")
- }
-
- @Test
- fun testPatch() {
- val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
- val response = restClientService.exchangeResource(HttpMethod.PATCH.name, "/sample/name", "")
- assertEquals("Patch request successful", response, "failed to get patch response")
- }
-
-}
-
-@RestController
-@RequestMapping("/sample")
-open class SampleController {
- @GetMapping("/name")
- fun getName(): String = "Sample Controller"
- @PatchMapping("/name")
- fun patchName(): String = "Patch request successful"
-}
-
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
deleted file mode 100644
index f9ec9fe5..00000000
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.test" level="warn"/>
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>