aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org/onap/portal
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-08-16 07:15:07 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-08-16 08:19:43 +0000
commit7c0e2f563a18dfe7c8f6c2ad66d01775c9468f37 (patch)
tree93ec77e83d0eb035c26a7f4e3017a7ee9f2e4f91 /app/src/main/java/org/onap/portal
parent6ae8df1305d1374af3b5ffe8ecb4c5ce3e17260d (diff)
Consistently use the preferences name in the preferences code base
- rename package name from org.onap.portal.prefs to org.onap.portalng.preferences - replace all other occurences of portal-prefs with preferences Other: - remove Sonarqube plugin Issue-ID: PORTALNG-39 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: Iced79a26460d988c5b22eb5fcac86d350528a1a2
Diffstat (limited to 'app/src/main/java/org/onap/portal')
-rw-r--r--app/src/main/java/org/onap/portal/prefs/PortalPrefsApplication.java37
-rw-r--r--app/src/main/java/org/onap/portal/prefs/configuration/BeansConfig.java35
-rw-r--r--app/src/main/java/org/onap/portal/prefs/configuration/LogInterceptor.java59
-rw-r--r--app/src/main/java/org/onap/portal/prefs/configuration/PortalPrefsConfig.java36
-rw-r--r--app/src/main/java/org/onap/portal/prefs/configuration/SecurityConfig.java53
-rw-r--r--app/src/main/java/org/onap/portal/prefs/controller/PreferencesController.java84
-rw-r--r--app/src/main/java/org/onap/portal/prefs/entities/PreferencesDto.java39
-rw-r--r--app/src/main/java/org/onap/portal/prefs/exception/ProblemException.java53
-rw-r--r--app/src/main/java/org/onap/portal/prefs/repository/PreferencesRepository.java28
-rw-r--r--app/src/main/java/org/onap/portal/prefs/services/PreferencesService.java80
-rw-r--r--app/src/main/java/org/onap/portal/prefs/util/IdTokenExchange.java88
-rw-r--r--app/src/main/java/org/onap/portal/prefs/util/Logger.java59
12 files changed, 0 insertions, 651 deletions
diff --git a/app/src/main/java/org/onap/portal/prefs/PortalPrefsApplication.java b/app/src/main/java/org/onap/portal/prefs/PortalPrefsApplication.java
deleted file mode 100644
index 092c533..0000000
--- a/app/src/main/java/org/onap/portal/prefs/PortalPrefsApplication.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs;
-
-import org.onap.portal.prefs.configuration.PortalPrefsConfig;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-
-@EnableConfigurationProperties(PortalPrefsConfig.class)
-@SpringBootApplication
-public class PortalPrefsApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(PortalPrefsApplication.class, args);
- }
-
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/configuration/BeansConfig.java b/app/src/main/java/org/onap/portal/prefs/configuration/BeansConfig.java
deleted file mode 100644
index 77ef7f0..0000000
--- a/app/src/main/java/org/onap/portal/prefs/configuration/BeansConfig.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.configuration;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.time.Clock;
-
-@Configuration
-public class BeansConfig {
- @Bean
- Clock clock() {
- return Clock.systemUTC();
- }
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/configuration/LogInterceptor.java b/app/src/main/java/org/onap/portal/prefs/configuration/LogInterceptor.java
deleted file mode 100644
index b653fe3..0000000
--- a/app/src/main/java/org/onap/portal/prefs/configuration/LogInterceptor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.configuration;
-
-import org.onap.portal.prefs.util.Logger;
-import org.springframework.stereotype.Component;
-import org.springframework.web.filter.reactive.ServerWebExchangeContextFilter;
-import org.springframework.web.server.ServerWebExchange;
-import org.springframework.web.server.WebFilter;
-import org.springframework.web.server.WebFilterChain;
-import reactor.core.publisher.Mono;
-
-import java.util.List;
-
-@Component
-public class LogInterceptor implements WebFilter {
- public static final String EXCHANGE_CONTEXT_ATTRIBUTE =
- ServerWebExchangeContextFilter.class.getName() + ".EXCHANGE_CONTEXT";
-
- public static final String X_REQUEST_ID = "X-Request-Id";
-
- @Override
- public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
- List<String> xRequestIdList = exchange.getRequest().getHeaders().get(X_REQUEST_ID);
- if (xRequestIdList != null && !xRequestIdList.isEmpty()) {
- String xRequestId = xRequestIdList.get(0);
- Logger.requestLog(
- xRequestId, exchange.getRequest().getMethod(), exchange.getRequest().getURI());
- exchange.getResponse().getHeaders().add(X_REQUEST_ID, xRequestId);
- exchange.getResponse().beforeCommit(() -> {
- Logger.responseLog(xRequestId,exchange.getResponse().getStatusCode());
- return Mono.empty();
- });
- }
-
- return chain
- .filter(exchange)
- .contextWrite(cxt -> cxt.put(EXCHANGE_CONTEXT_ATTRIBUTE, exchange));
- }
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/configuration/PortalPrefsConfig.java b/app/src/main/java/org/onap/portal/prefs/configuration/PortalPrefsConfig.java
deleted file mode 100644
index 2d415cd..0000000
--- a/app/src/main/java/org/onap/portal/prefs/configuration/PortalPrefsConfig.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.configuration;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-import jakarta.validation.constraints.NotBlank;
-import lombok.Data;
-
-@Data
-@ConfigurationProperties("portal-prefs")
-public class PortalPrefsConfig {
-
- @NotBlank
- private final String realm;
-
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/configuration/SecurityConfig.java b/app/src/main/java/org/onap/portal/prefs/configuration/SecurityConfig.java
deleted file mode 100644
index 531e90b..0000000
--- a/app/src/main/java/org/onap/portal/prefs/configuration/SecurityConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.configuration;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
-import org.springframework.security.config.web.server.ServerHttpSecurity;
-import org.springframework.security.web.server.SecurityWebFilterChain;
-
-/**
- * Configures the access control of the API endpoints.
- */
-// https://hantsy.github.io/spring-reactive-sample/security/config.html
-@EnableWebFluxSecurity
-@Configuration
-public class SecurityConfig {
-
- @Bean
- public SecurityWebFilterChain springSecurityWebFilterChain(ServerHttpSecurity http) {
- return http.httpBasic().disable()
- .formLogin().disable()
- .csrf().disable()
- .cors()
- .and()
- .authorizeExchange()
- .pathMatchers(HttpMethod.GET, "/actuator/**").permitAll()
- .anyExchange().authenticated()
- .and()
- .oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::jwt)
- .build();
- }
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/controller/PreferencesController.java b/app/src/main/java/org/onap/portal/prefs/controller/PreferencesController.java
deleted file mode 100644
index f2ae7f9..0000000
--- a/app/src/main/java/org/onap/portal/prefs/controller/PreferencesController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.controller;
-import org.onap.portal.prefs.exception.ProblemException;
-import org.onap.portal.prefs.openapi.api.PreferencesApi;
-import org.onap.portal.prefs.openapi.model.Preferences;
-import org.onap.portal.prefs.services.PreferencesService;
-import org.onap.portal.prefs.util.IdTokenExchange;
-import org.onap.portal.prefs.util.Logger;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.server.ServerWebExchange;
-
-import reactor.core.publisher.Mono;
-
-@RestController
-public class PreferencesController implements PreferencesApi {
-
-
- private final PreferencesService preferencesService;
-
- public PreferencesController(PreferencesService getPreferences){
- this.preferencesService = getPreferences;
- }
-
- @Override
- public Mono<ResponseEntity<Preferences>> getPreferences(String xRequestId, ServerWebExchange exchange) {
- return IdTokenExchange
- .extractUserId(exchange)
- .flatMap(userid ->
- preferencesService.getPreferences(userid)
- .map(ResponseEntity::ok))
- .onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user preferences", null, "portal-prefs" );
- return Mono.error(ex);
- })
- .onErrorReturn(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
-
- }
-
- @Override
- public Mono<ResponseEntity<Preferences>> savePreferences(String xRequestId, Mono<Preferences> preferences,
- ServerWebExchange exchange) {
- return IdTokenExchange
- .extractUserId(exchange)
- .flatMap(userid ->
- preferences
- .flatMap( pref ->
- preferencesService
- .savePreferences(xRequestId, userid, pref)))
- .map( ResponseEntity::ok)
- .onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user preferences", null, "portal-prefs" );
- return Mono.error(ex);
- })
- .onErrorReturn(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
- }
-
- @Override
- public Mono<ResponseEntity<Preferences>> updatePreferences(String xRequestId, Mono<Preferences> preferences, ServerWebExchange exchange) {
- return savePreferences(xRequestId, preferences, exchange);
- }
-
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/entities/PreferencesDto.java b/app/src/main/java/org/onap/portal/prefs/entities/PreferencesDto.java
deleted file mode 100644
index 45616a9..0000000
--- a/app/src/main/java/org/onap/portal/prefs/entities/PreferencesDto.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.entities;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.data.annotation.Id;
-import org.springframework.data.mongodb.core.mapping.Document;
-
-@Document
-@Getter
-@Setter
-public class PreferencesDto {
- @Id
- private String userId;
-
- private Object properties;
-
-}
-
diff --git a/app/src/main/java/org/onap/portal/prefs/exception/ProblemException.java b/app/src/main/java/org/onap/portal/prefs/exception/ProblemException.java
deleted file mode 100644
index b9d2a3d..0000000
--- a/app/src/main/java/org/onap/portal/prefs/exception/ProblemException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.exception;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-import org.zalando.problem.AbstractThrowableProblem;
-import org.zalando.problem.Problem;
-import org.zalando.problem.Status;
-import org.zalando.problem.StatusType;
-
-import java.net.URI;
-
-/** The default portal-prefs exception */
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-@EqualsAndHashCode(callSuper = true)
-public class ProblemException extends AbstractThrowableProblem {
- @Builder.Default private final URI type = Problem.DEFAULT_TYPE;
-
- @Builder.Default private final String title = "Bad preferences error";
-
- @Builder.Default private final StatusType status = Status.BAD_REQUEST;
-
- @Builder.Default private final String detail = "Please add more details here";
-
- @Builder.Default private final URI instance = null;
-
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/repository/PreferencesRepository.java b/app/src/main/java/org/onap/portal/prefs/repository/PreferencesRepository.java
deleted file mode 100644
index 461ee1d..0000000
--- a/app/src/main/java/org/onap/portal/prefs/repository/PreferencesRepository.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.repository;
-
-import org.onap.portal.prefs.entities.PreferencesDto;
-import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
-
-public interface PreferencesRepository extends ReactiveMongoRepository<PreferencesDto, String> {
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/services/PreferencesService.java b/app/src/main/java/org/onap/portal/prefs/services/PreferencesService.java
deleted file mode 100644
index f96dfea..0000000
--- a/app/src/main/java/org/onap/portal/prefs/services/PreferencesService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.services;
-
-import org.onap.portal.prefs.entities.PreferencesDto;
-import org.onap.portal.prefs.exception.ProblemException;
-import org.onap.portal.prefs.openapi.model.Preferences;
-import org.onap.portal.prefs.repository.PreferencesRepository;
-import org.onap.portal.prefs.util.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import reactor.core.publisher.Mono;
-
-@Service
-public class PreferencesService {
-
- @Autowired
- private PreferencesRepository repository;
-
- public Mono<Preferences> getPreferences(String userId){
- return repository
- .findById(userId)
- .switchIfEmpty(defaultPreferences())
- .map(this::toPreferences);
- }
-
- public Mono<Preferences> savePreferences( String xRequestId, String userId, Preferences preferences){
-
- var preferencesDto = new PreferencesDto();
- preferencesDto.setUserId(userId);
- preferencesDto.setProperties(preferences.getProperties());
-
- return repository
- .save(preferencesDto)
- .map(this::toPreferences)
- .onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user prefrences", userId, "portal-prefs" );
- return Mono.error(ex);
- });
-
- }
-
- private Preferences toPreferences(PreferencesDto preferencesDto) {
- var preferences = new Preferences();
- preferences.setProperties(preferencesDto.getProperties());
- return preferences;
- }
-
- /**
- * Get a Preferences object that is initialised with an empty string.
- * This is a) for convenience to not handle 404 on the consuming side and
- * b) for security reasons
- * @return PreferencesDto
- */
- private Mono<PreferencesDto> defaultPreferences() {
- var preferencesDto = new PreferencesDto();
- preferencesDto.setProperties("");
- return Mono.just(preferencesDto);
- }
-}
diff --git a/app/src/main/java/org/onap/portal/prefs/util/IdTokenExchange.java b/app/src/main/java/org/onap/portal/prefs/util/IdTokenExchange.java
deleted file mode 100644
index 9ac2794..0000000
--- a/app/src/main/java/org/onap/portal/prefs/util/IdTokenExchange.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.util;
-
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.JWTParser;
-
-import java.text.ParseException;
-
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-/**
- * Represents a function that handles the <a href="https://jwt.io/introduction">JWT</a> identity token.
- * Use this to check if the incoming requests are authorized to call the given endpoint
- */
-
-public final class IdTokenExchange {
-
- public static final String X_AUTH_IDENTITY_HEADER = "X-Auth-Identity";
- public static final String JWT_CLAIM_USERID = "sub";
-
- private IdTokenExchange(){
-
- }
-
- /**
- * Extract the identity header from the given {@link ServerWebExchange}.
- * @param exchange the ServerWebExchange that contains information about the incoming request
- * @return the identity header in the form of <code>Bearer {@literal <Token>}<c/ode>
- */
- private static Mono<String> extractIdentityHeader(ServerWebExchange exchange) {
- return Mono.just(exchange.getRequest().getHeaders().getOrEmpty(X_AUTH_IDENTITY_HEADER))
- .map(headers -> headers.get(0))
- .onErrorResume(Exception.class, ex -> Mono.error(ex));
- }
-
- /**
- * Extract the identity token from the given {@link ServerWebExchange}.
- * @see <a href="https://openid.net/specs/openid-connect-core-1_0.html#IDToken">OpenId Connect ID Token</a>
- * @param exchange the ServerWebExchange that contains information about the incoming request
- * @return the identity token that contains user roles
- */
- private static Mono<String> extractIdToken(ServerWebExchange exchange) {
- return extractIdentityHeader(exchange)
- .map(identityHeader -> identityHeader.replace("Bearer ", ""));
- }
-
- /**
- * Extract the <code>userId</code> from the given {@link ServerWebExchange}
- * @param exchange the ServerWebExchange that contains information about the incoming request
- * @return the id of the user
- */
- public static Mono<String> extractUserId(ServerWebExchange exchange) {
- return extractIdToken(exchange)
- .flatMap(idToken -> extractUserClaim(idToken));
- }
-
- private static Mono<String> extractUserClaim(String idToken) {
- JWTClaimsSet jwtClaimSet;
- try {
- jwtClaimSet = JWTParser.parse(idToken).getJWTClaimsSet();
- } catch (ParseException e) {
- return Mono.error(e);
- }
- return Mono.just(String.class.cast(jwtClaimSet.getClaim(JWT_CLAIM_USERID)));
- }
-}
-
diff --git a/app/src/main/java/org/onap/portal/prefs/util/Logger.java b/app/src/main/java/org/onap/portal/prefs/util/Logger.java
deleted file mode 100644
index 4026b9f..0000000
--- a/app/src/main/java/org/onap/portal/prefs/util/Logger.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * Copyright (c) 2022. Deutsche Telekom AG
- *
- * 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.portal.prefs.util;
-
-import java.net.URI;
-
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatusCode;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class Logger {
-
- private Logger(){}
-
- public static void requestLog(String xRequestId, HttpMethod methode, URI path) {
- log.info("Portal-prefs - request - X-Request-Id {} {} {}", xRequestId, methode, path);
- }
-
- public static void responseLog(String xRequestId, HttpStatusCode httpStatusCode) {
- log.info("Portal-prefs - response - X-Request-Id {} {}", xRequestId, httpStatusCode);
- }
-
- public static void errorLog(String xRequestId, String msg, String id, String app) {
- log.info(
- "Portal-prefs - error - X-Request-Id {} {} {} not found in {}", xRequestId, msg, id, app);
- }
-
- public static void errorLog(
- String xRequestId, String msg, String id, String app, String errorDetails) {
- log.info(
- "Portal-prefs - error - X-Request-Id {} {} {} not found in {} error message: {}",
- xRequestId,
- msg,
- id,
- app,
- errorDetails);
- }
-}