import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider;
-import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.configuration.HttpHeadersProvider;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.slf4j.Logger;
package org.onap.so.adapters.vevnfm.provider;
import org.apache.logging.log4j.util.Strings;
-import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
+import org.onap.so.configuration.BasicHttpHeadersProvider;
public class AuthorizationHeadersProvider extends BasicHttpHeadersProvider {
* 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.
@Profile("test")
@ComponentScan(
basePackages = {"org.onap.so.asdc", "org.onap.so.security", "org.onap.so.rest.service",
- "org.onap.so.configuration.rest", "org.onap.so.client"},
+ "org.onap.so.configuration", "org.onap.so.client"},
excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class)})
jdbc-url: jdbc:mariadb://localhost:3307/catalogdb
username: root
password: password
- driver-class-name: org.mariadb.jdbc.Driver
+ driver-class-name: org.mariadb.jdbc.Driver
initialization-mode: always
- jpa:
+ jpa:
generate-ddl: false
show-sql: true
hibernate:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
security:
usercredentials:
- -
+ -
username: test
password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
- role: Asdc-Client
+ role: Asdc-Client
+ sleuth:
+ enabled: false
mariaDB4j:
- dataDir:
+ dataDir:
port: 3307
databaseName: catalogdb
databaseName2: requestdb
-
+
request:
datasource:
jdbc-url: jdbc:mariadb://localhost:3307/requestdb
export:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
- step: 1m # Step size (i.e. reporting frequency) to use.
+ step: 1m # Step size (i.e. reporting frequency) to use.
mso:
adapters:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
- endpoint: http://localhost:8081
+ endpoint: http://localhost:8081
logPath: logs
catalog:
db:
spring:
endpoint: "http://localhost:"
- camundaURL: http://localhost:${wiremock.server.port}/
+ camundaURL: http://localhost:${wiremock.server.port}/
db:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
site-name: siteName
pollingTimeout: 30
relevantArtifactTypes: HEAT,HEAT_ENV,HEAT_VOL
activateServerTLSAuth: false
- keyStorePassword:
+ keyStorePassword:
keyStorePath:
watchDogTimeout: 1
isFilterInEmptyResources: true
sdc:
endpoint: http://localhost:${wiremock.server.port}
-
\ No newline at end of file
import javax.ws.rs.core.MediaType;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
-import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
+import org.onap.so.configuration.HttpComponentsClientConfiguration;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
-import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
-import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.configuration.BasicHttpHeadersProvider;
+import org.onap.so.configuration.HttpHeadersProvider;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.slf4j.Logger;
/**
* Provides {@link org.onap.so.rest.service.VnfmAdapterServiceProvider} configuration for
* {@link VnfmAdapterCreateVnfTask}
- *
+ *
* @author waqas.ikram@est.tech
*/
@Configuration
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
+import org.onap.so.configuration.HttpComponentsClientConfiguration;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
* 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.
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.so.client.CommonObjectMapperProvider;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
--- /dev/null
+<?xml version="1.0" ?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>1.16.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>clients-base</artifactId>
+ <properties>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>logger</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.javatuples</groupId>
+ <artifactId>javatuples</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>net.jodah</groupId>
+ <artifactId>failsafe</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.1.2</version>
+ <configuration>
+ <systemPropertyVariables>
+ <so.log.level>DEBUG</so.log.level>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
* ============LICENSE_END=========================================================
*/
-package org.onap.so.client.policy;
+package org.onap.so.client;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
package org.onap.so.client;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.net.URL;
import java.util.Optional;
import javax.ws.rs.core.MultivaluedMap;
/**
* Adds a basic authentication header to the request.
- *
+ *
* @param auth the encrypted credentials
* @param key the key for decrypting the credentials
*/
/**
* Adds an additional header to the header map
- *
+ *
* @param encoded basic auth value
*/
public void addAdditionalHeader(String name, String value) {
}
}
+ private static boolean isNotBlank(String str) {
+ return str != null && !str.trim().isEmpty();
+ }
+
}
import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.filter.base.ONAPComponentsList;
import org.onap.logging.filter.base.PayloadLoggingClientFilter;
-import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.logging.jaxrs.filter.SOMetricLogClientFilter;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
/**
* Adds a basic authentication header to the request.
- *
+ *
* @param auth the encrypted credentials
* @param key the key for decrypting the credentials
*/
package org.onap.so.client;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
-import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
+import org.onap.so.configuration.HttpComponentsClientConfiguration;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
* ============LICENSE_END=========================================================
*/
-package org.onap.so.configuration.rest;
+package org.onap.so.configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
* ============LICENSE_END=========================================================
*/
-package org.onap.so.configuration.rest;
+package org.onap.so.configuration;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Value;
/**
* This class is used configure the parameters needed for {@link org.apache.http.impl.client.CloseableHttpClient}
- *
+ *
* @author waqas.ikram@est.tech
*/
@Service
* 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.so.configuration.rest;
+package org.onap.so.configuration;
import java.util.concurrent.TimeUnit;
import org.apache.http.client.config.RequestConfig;
/**
* Allow user to configure {@link org.apache.http.client.HttpClient}
- *
+ *
* @author waqas.ikram@est.tech
*/
@Configuration
* ============LICENSE_END=========================================================
*/
-package org.onap.so.configuration.rest;
+package org.onap.so.configuration;
import org.springframework.http.HttpHeaders;
/**
* Providers {@link org.springframework.http.HttpHeaders} for HTTP requests
- *
+ *
* @author waqas.ikram@est.tech
*
*/
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.utils;
+
+
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
+import org.onap.so.logger.MessageEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.crypto.Cipher;
+import javax.crypto.spec.GCMParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.GeneralSecurityException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+
+
+/**
+ * CryptoUtils adapted from RTTP client.
+ *
+ */
+public final class CryptoUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(CryptoUtils.class);
+
+
+ private static final String AES = "AES";
+ private static final String CLOUD_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
+ private static final int GCM_TAG_LENGTH = 16;
+ private static final int GCM_IV_LENGTH = 12;
+ private static final String AES_GCM_NO_PADDING = "AES/GCM/NoPadding";
+
+ /**
+ * encrypt a value and generate a keyfile if the keyfile is not found then a new one is created
+ *
+ * @throws GeneralSecurityException
+ */
+ public static String encrypt(String value, String keyString) throws GeneralSecurityException {
+ SecretKeySpec sks = getSecretKeySpec(keyString);
+ Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING);
+ byte[] initVector = new byte[GCM_IV_LENGTH];
+ (new SecureRandom()).nextBytes(initVector);
+ GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector);
+ cipher.init(Cipher.ENCRYPT_MODE, sks, spec);
+ byte[] encoded = value.getBytes(java.nio.charset.StandardCharsets.UTF_8);
+ byte[] cipherText = new byte[initVector.length + cipher.getOutputSize(encoded.length)];
+ System.arraycopy(initVector, 0, cipherText, 0, initVector.length);
+ cipher.doFinal(encoded, 0, encoded.length, cipherText, initVector.length);
+ return byteArrayToHexString(cipherText);
+ }
+
+ /**
+ * decrypt a value
+ *
+ * @throws GeneralSecurityException
+ */
+ public static String decrypt(String message, String keyString) throws GeneralSecurityException {
+ if (message.equals(System.getenv("PLAINTEXTPASSWORD")))
+ return message;
+ SecretKeySpec sks = getSecretKeySpec(keyString);
+ byte[] cipherText = hexStringToByteArray(message);
+ Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING);
+ byte[] initVector = Arrays.copyOfRange(cipherText, 0, GCM_IV_LENGTH);
+ GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * java.lang.Byte.SIZE, initVector);
+ cipher.init(Cipher.DECRYPT_MODE, sks, spec);
+ byte[] plaintext = cipher.doFinal(cipherText, GCM_IV_LENGTH, cipherText.length - GCM_IV_LENGTH);
+ return new String(plaintext);
+ }
+
+ public static String encryptCloudConfigPassword(String message) {
+ try {
+ return CryptoUtils.encrypt(message, CLOUD_KEY);
+ } catch (GeneralSecurityException e) {
+ logger.error(LoggingAnchor.THREE, MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ ErrorCode.BusinessProcessError.getValue(), "Exception in encryptPassword ", e);
+ return null;
+ }
+ }
+
+ public static String decryptCloudConfigPassword(String message) {
+ try {
+ return CryptoUtils.decrypt(message, CLOUD_KEY);
+ } catch (GeneralSecurityException e) {
+ logger.error(LoggingAnchor.THREE, MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ ErrorCode.BusinessProcessError.getValue(), "Exception in encryptPassword ", e);
+ return null;
+ }
+ }
+
+ private static SecretKeySpec getSecretKeySpec(String keyString) {
+ byte[] key = hexStringToByteArray(keyString);
+ return new SecretKeySpec(key, AES);
+ }
+
+ public static String byteArrayToHexString(byte[] b) {
+ StringBuilder sb = new StringBuilder(b.length * 2);
+ for (byte aB : b) {
+ int v = aB & 0xff;
+ if (v < 16) {
+ sb.append('0');
+ }
+ sb.append(Integer.toHexString(v));
+ }
+ return sb.toString().toUpperCase();
+ }
+
+ private static byte[] hexStringToByteArray(String s) {
+ byte[] b = new byte[s.length() / 2];
+ for (int i = 0; i < b.length; i++) {
+ int index = i * 2;
+ int v = Integer.parseInt(s.substring(index, index + 2), 16);
+ b[i] = (byte) v;
+ }
+ return b;
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.mockito.Mockito.when;
+import java.util.Collections;
+import java.util.List;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.core.MultivaluedHashMap;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import lombok.SneakyThrows;
+
+@ExtendWith(MockitoExtension.class)
+public class AddCacheHeadersTest {
+
+ @Mock
+ ClientRequestContext request;
+
+ @Mock
+ ClientResponseContext response;
+
+ private final AddCacheHeaders addCacheHeaders = new AddCacheHeaders(new CachePropertiesImpl());
+
+ @Test
+ @SneakyThrows
+ public void thatCacheHeaderIsAddedForGet() {
+ MultivaluedHashMap<String, String> headers = new MultivaluedHashMap<>();
+ when(request.getMethod()).thenReturn("GET");
+ when(response.getHeaders()).thenReturn(headers);
+
+ addCacheHeaders.filter(request, response);
+ assertTrue(headers.containsKey("Cache-Control"));
+ assertEquals(Collections.singletonList("public, max-age=" + (new CachePropertiesImpl().getMaxAge() / 1000)),
+ headers.get("Cache-Control"));
+ }
+
+ @Test
+ @SneakyThrows
+ public void thatCacheHeaderIsNotOverwrittenForGet() {
+ MultivaluedHashMap<String, String> headers = new MultivaluedHashMap<>();
+ List<String> expected = Collections.singletonList("foo");
+ headers.put("Cache-Control", expected);
+ when(request.getMethod()).thenReturn("GET");
+ when(response.getHeaders()).thenReturn(headers);
+
+ addCacheHeaders.filter(request, response);
+ assertTrue(headers.containsKey("Cache-Control"));
+ assertEquals(expected, headers.get("Cache-Control"));
+ }
+
+ @Test
+ @SneakyThrows
+ public void thatCacheHeaderIsNotAddedForOtherMethods() {
+ MultivaluedHashMap<String, String> headers = new MultivaluedHashMap<>();
+ when(request.getMethod()).thenReturn("PUT");
+
+ addCacheHeaders.filter(request, response);
+ assertFalse(headers.containsKey("Cache-Control"));
+ }
+
+ class CachePropertiesImpl implements CacheProperties {
+
+ @Override
+ public String getCacheName() {
+ return "test-cache";
+ }
+
+ @Override
+ public Long getMaxAge() {
+ return 5 * 60 * 1000L;
+ }
+
+ }
+}
* ============LICENSE_END=========================================================
*/
-package org.onap.so.configuration.rest;
+package org.onap.so.configuration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.onap.so.configuration.rest.BasicHttpHeadersProvider.AUTHORIZATION_HEADER;
+import static org.onap.so.configuration.BasicHttpHeadersProvider.AUTHORIZATION_HEADER;
import java.util.Arrays;
import org.junit.Test;
+import org.onap.so.configuration.BasicHttpHeadersProvider;
+import org.onap.so.configuration.HttpHeadersProvider;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
* ============LICENSE_END=========================================================
*/
-package org.onap.so.configuration.rest;
+package org.onap.so.configuration;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
<logback.version>1.2.13</logback.version>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>logger</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>clients-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
- <dependency>
- <groupId>net.jodah</groupId>
- <artifactId>failsafe</artifactId>
- <version>2.0.1</version>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${grpc.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.javatuples</groupId>
- <artifactId>javatuples</artifactId>
- <version>1.2</version>
- </dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-external-task-client</artifactId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
- <dependency>
- <groupId>javax.cache</groupId>
- <artifactId>cache-api</artifactId>
- <version>1.1.0</version>
- </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
* 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.
import org.apache.commons.codec.binary.Base64;
import org.javatuples.Pair;
import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.client.CommonObjectMapperProvider;
import org.onap.so.client.RestClient;
-import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.utils.CryptoUtils;
* 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.
package org.onap.so.client.policy;
+import org.onap.so.client.CommonObjectMapperProvider;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
package org.onap.so.rest.service;
-import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.configuration.HttpHeadersProvider;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
import org.onap.so.rest.exceptions.RestProcessingException;
}
/**
- *
+ *
* @deprecated this constructor is deprecated in favor of using {@link HttpRestServiceProviderImpl(RestTemplate
* restTemplate, HttpHeaders defaultHttpHeaders)}
*/
* 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.
package org.onap.so.utils;
-import org.onap.so.logger.LoggingAnchor;
import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* CryptoUtils adapted from RTTP client.
- *
+ *
*/
public final class CryptoUtils {
/**
* encrypt a value and generate a keyfile if the keyfile is not found then a new one is created
- *
+ *
* @throws GeneralSecurityException
*/
public static String encrypt(String value, String keyString) throws GeneralSecurityException {
/**
* decrypt a value
- *
+ *
* @throws GeneralSecurityException
*/
public static String decrypt(String message, String keyString) throws GeneralSecurityException {
* 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.
* 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.
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.sax.SAXSource;
-import org.onap.so.logger.LoggingAnchor;
import org.onap.so.exceptions.MarshallerException;
-import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
+import org.onap.logging.filter.base.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
--- /dev/null
+<?xml version="1.0" ?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>1.16.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>logger</artifactId>
+ <properties>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.1.2</version>
+ <configuration>
+ <systemPropertyVariables>
+ <so.log.level>DEBUG</so.log.level>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- ideally these would just be grouped under a .entities package
+ but that would change the imports everywhere these are used -->
+ <exclude>org/onap/so/logger/HttpHeadersConstants</exclude>
+ <exclude>org/onap/so/logger/LogConstants</exclude>
+ <exclude>org/onap/so/logger/LoggingAnchor</exclude>
+ <exclude>org/onap/so/logger/MdcConstants</exclude>
+ <exclude>org/onap/so/logger/MessageEnum</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
* 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.
* 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.
private String patternsProperty;
private String maskChar = "*";
private Optional<Pattern> pattern = Optional.empty();
- private static final Pattern authPattern =
- Pattern.compile("Authorization(?:\\:|=)\\s?(?:\"|\\[)(?:Basic|Bearer) (.*?)(?:\"|\\])");
+ private static final String authPatternString = "Authorization[: ]+(?:Bearer|Basic)\\s(\\S+)";
+ private static final Pattern authPattern = Pattern.compile(authPatternString);
private static final Pattern openstackPattern = Pattern.compile("\"password\"\\s?:\\s?\"(.*?)\"");
public String getPatternsProperty() {
@Override
public String doLayout(ILoggingEvent event) {
- final StringBuilder message = new StringBuilder(super.doLayout(event));
+ // final StringBuilder message = new StringBuilder(super.doLayout(event));
+ final StringBuilder message = new StringBuilder(event.getFormattedMessage());
List<Pattern> patterns = new ArrayList<>(getPatterns());
if (pattern.isPresent()) {
patterns.add(pattern.get());
* 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.
* 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.
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.logger;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+import java.net.UnknownHostException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import ch.qos.logback.core.Context;
+
+@ExtendWith(MockitoExtension.class)
+public class LoggerStartupListenerTest {
+
+ private LoggerStartupListener loggerStartupListener;
+
+ @Mock
+ private Context context;
+
+ @BeforeEach
+ public void setUp() {
+ loggerStartupListener = new LoggerStartupListener();
+ loggerStartupListener.setContext(context);
+ }
+
+ @Test
+ public void thatServerNameIsSetOnStartup() throws UnknownHostException {
+ loggerStartupListener.start();
+
+ verify(context).putProperty(eq("server.name"), anyString());
+ assertTrue(loggerStartupListener.isStarted());
+ }
+}
--- /dev/null
+package org.onap.so.logger;
+
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import ch.qos.logback.classic.spi.LoggingEvent;
+
+@ExtendWith(MockitoExtension.class)
+public class MaskLogStatementsTest {
+
+ private MaskLogStatements maskLogStatements;
+
+ @BeforeEach
+ public void setUp() {
+ maskLogStatements = new MaskLogStatements();
+ }
+
+ @Test
+ public void testDoLayoutShouldMaskAuthorizationToken() {
+ String logMessage = "Authorization: Bearer mySecretToken123";
+
+ LoggingEvent loggingEvent = new LoggingEvent();
+ loggingEvent.setMessage(logMessage);
+
+ String maskedMessage = maskLogStatements.doLayout(loggingEvent);
+
+ assertEquals("Authorization: Bearer ****************", maskedMessage);
+ }
+}
<artifactId>common</artifactId>
<packaging>pom</packaging>
<modules>
+ <module>logger</module>
+ <module>clients-base</module>
<module>common</module>
</modules>
</project>
package org.onap.aaiclient.client.graphinventory;
-import org.onap.so.client.policy.CommonObjectMapperProvider;
+import org.onap.so.client.CommonObjectMapperProvider;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import org.onap.so.client.ResponseExceptionMapper;
import org.onap.so.client.RestClientSSL;
import org.onap.so.client.RestProperties;
-import org.onap.so.client.policy.CommonObjectMapperProvider;
+import org.onap.so.client.CommonObjectMapperProvider;
+import org.onap.so.objects.audit.AAIObjectAudit;
public abstract class GraphInventoryRestClient extends RestClientSSL {