diff options
author | baniewsk <pawel.baniewski@nokia.com> | 2020-07-29 16:01:27 +0200 |
---|---|---|
committer | Pawel <pawel.kasperkiewicz@nokia.com> | 2020-08-05 14:18:54 +0200 |
commit | b8c4e6867d6b26652f4382e93665c220769cdc9f (patch) | |
tree | bb60a44b012731e3ee6fdffe2466f5ed7d6b5c7b /certService/src/main/java/org/onap/aaf/certservice/api | |
parent | fc31c9e47b3e08f8914dcd1f0c5b6d18aa625567 (diff) |
Removing AAF references from Cert-Service in OOM repo.
Certificates regenerated
External files (from legacy AAF) removed
Still left:
* Sonar link,
* Link to documentation,
* Names of K8s resources in RTD documentation,
* Link to CSITs
Issue-ID: OOM-2526
Signed-off-by: Pawel Baniewski <pawel.baniewski@nokia.com>
Change-Id: I675f7485160b9b8e46e9ea573550e62ed28ca607
Diffstat (limited to 'certService/src/main/java/org/onap/aaf/certservice/api')
6 files changed, 0 insertions, 408 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java b/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java deleted file mode 100644 index c440ec34..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/CertificationController.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.onap.aaf.certservice.certification.CertificationModelFactory; -import org.onap.aaf.certservice.certification.exception.DecryptionException; -import org.onap.aaf.certservice.certification.exception.ErrorResponseModel; -import org.onap.aaf.certservice.certification.model.CertificationModel; -import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@Tag(name = "CertificationService") -public class CertificationController { - - private static final Logger LOGGER = LoggerFactory.getLogger(CertificationController.class); - - private final CertificationModelFactory certificationModelFactory; - - @Autowired - CertificationController(CertificationModelFactory certificationModelFactory) { - this.certificationModelFactory = certificationModelFactory; - } - - /** - * Request for signing certificate by given CA. - * - * @param caName the name of Certification Authority that will sign root certificate - * @param encodedCsr Certificate Sign Request encoded in Base64 form - * @param encodedPrivateKey Private key for CSR, needed for PoP, encoded in Base64 form - * @return JSON containing trusted certificates and certificate chain - */ - @GetMapping(value = "v1/certificate/{caName}", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Certificate successfully signed"), - @ApiResponse(responseCode = "400", description = "Given CSR or/and PK is incorrect", - content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))), - @ApiResponse(responseCode = "404", description = "CA not found for given name", - content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))), - @ApiResponse(responseCode = "500", description = "Something went wrong during connectiion to CMPv2 server", - content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))) - }) - @Operation( - summary = "sign certificate", - description = "Web endpoint for requesting certificate signing. Used by system components to gain certificate signed by CA.", - tags = {"CertificationService"}) - public ResponseEntity<CertificationModel> signCertificate( - @Parameter(description = "Name of certification authority that will sign CSR.") - @PathVariable String caName, - @Parameter(description = "Certificate signing request in form of PEM object encoded in Base64 (with header and footer).") - @RequestHeader("CSR") String encodedCsr, - @Parameter(description = "Private key in form of PEM object encoded in Base64 (with header and footer).") - @RequestHeader("PK") String encodedPrivateKey - ) throws DecryptionException, CmpClientException { - caName = caName.replaceAll("[\n|\r|\t]", "_"); - LOGGER.info("Received certificate signing request for CA named: {}", caName); - CertificationModel certificationModel = certificationModelFactory - .createCertificationModel(encodedCsr, encodedPrivateKey, caName); - return new ResponseEntity<>(certificationModel, HttpStatus.OK); - } - -} diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java b/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java deleted file mode 100644 index 9c8e1bf0..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/ReadinessController.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.onap.aaf.certservice.certification.configuration.CmpServersConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Tag(name = "CertificationService") -public final class ReadinessController { - - private final CmpServersConfig cmpServersConfig; - - @Autowired - public ReadinessController(CmpServersConfig cmpServersConfig) { - this.cmpServersConfig = cmpServersConfig; - } - - @GetMapping(value = "/ready", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Configuration is loaded and service is ready to use"), - @ApiResponse(responseCode = "503", description = "Configuration loading failed and service is unavailable") - }) - @Operation( - summary = "Check if CertService application is ready", - description = "Web endpoint for checking if service is ready to be used.", - tags = {"CertificationService"}) - public ResponseEntity<String> checkReady() { - if (cmpServersConfig.isReady()) { - return new ResponseEntity<>(HttpStatus.OK); - } else { - return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE); - } - } -} diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java b/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java deleted file mode 100644 index 14bff8dd..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/ReloadConfigController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.onap.aaf.certservice.certification.configuration.CmpServersConfig; -import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException; -import org.onap.aaf.certservice.certification.exception.ErrorResponseModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Tag(name = "CertificationService") -public final class ReloadConfigController { - - private final CmpServersConfig cmpServersConfig; - - @Autowired - public ReloadConfigController(CmpServersConfig cmpServersConfig) { - this.cmpServersConfig = cmpServersConfig; - } - - @GetMapping(value = "/reload", produces = "application/json") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Configuration has been successfully reloaded"), - @ApiResponse(responseCode = "500", description = "Something went wrong during configuration loading", - content = @Content(schema = @Schema(implementation = ErrorResponseModel.class))) - }) - @Operation( - summary = "Reload CMPv2 servers configuration from configuration file", - description = "Web endpoint for performing configuration reload. Used to reload configuration from file.", - tags = {"CertificationService"}) - public ResponseEntity<String> reloadConfiguration() throws CmpServersConfigLoadingException { - cmpServersConfig.reloadConfiguration(); - return new ResponseEntity<>(HttpStatus.OK); - } - -} diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java b/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java deleted file mode 100644 index a40fea8f..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/advice/CertificationExceptionAdvice.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api.advice; - -import org.onap.aaf.certservice.api.CertificationController; -import org.onap.aaf.certservice.certification.exception.Cmpv2ClientAdapterException; -import org.onap.aaf.certservice.certification.exception.Cmpv2ServerNotFoundException; -import org.onap.aaf.certservice.certification.exception.CsrDecryptionException; -import org.onap.aaf.certservice.certification.exception.ErrorResponseModel; -import org.onap.aaf.certservice.certification.exception.KeyDecryptionException; -import org.onap.aaf.certservice.cmpv2client.exceptions.CmpClientException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice(assignableTypes = CertificationController.class) -public final class CertificationExceptionAdvice { - - private static final Logger LOGGER = LoggerFactory.getLogger(CertificationExceptionAdvice.class); - - @ExceptionHandler(value = CsrDecryptionException.class) - public ResponseEntity<ErrorResponseModel> handle(CsrDecryptionException exception) { - LOGGER.error("Exception occurred during decoding certificate sign request:", exception); - return getErrorResponseEntity( - "Wrong certificate signing request (CSR) format", - HttpStatus.BAD_REQUEST - ); - } - - @ExceptionHandler(value = KeyDecryptionException.class) - public ResponseEntity<ErrorResponseModel> handle(KeyDecryptionException exception) { - LOGGER.error("Exception occurred during decoding key:", exception); - return getErrorResponseEntity( - "Wrong key (PK) format", - HttpStatus.BAD_REQUEST - ); - } - - @ExceptionHandler(value = Cmpv2ServerNotFoundException.class) - public ResponseEntity<ErrorResponseModel> handle(Cmpv2ServerNotFoundException exception) { - LOGGER.error("Exception occurred selecting CMPv2 server:", exception); - return getErrorResponseEntity( - "Certification authority not found for given CAName", - HttpStatus.NOT_FOUND - ); - } - - @ExceptionHandler(value = RuntimeException.class) - public ResponseEntity<ErrorResponseModel> handle(RuntimeException exception) throws CmpClientException { - throw new CmpClientException("Runtime exception occurred calling cmp client business logic", exception); - } - - @ExceptionHandler(value = CmpClientException.class) - public ResponseEntity<ErrorResponseModel> handle(CmpClientException exception) { - LOGGER.error("Exception occurred calling cmp client:", exception); - return getErrorResponseEntity( - "Exception occurred during call to cmp client", - HttpStatus.INTERNAL_SERVER_ERROR - ); - } - - @ExceptionHandler(value = Cmpv2ClientAdapterException.class) - public ResponseEntity<ErrorResponseModel> handle(Cmpv2ClientAdapterException exception) { - LOGGER.error("Exception occurred parsing cmp client response:", exception); - return getErrorResponseEntity( - "Exception occurred parsing cmp client response", - HttpStatus.INTERNAL_SERVER_ERROR - ); - } - - private ResponseEntity<ErrorResponseModel> getErrorResponseEntity(String errorMessage, HttpStatus status) { - ErrorResponseModel errorResponse = new ErrorResponseModel(errorMessage); - return new ResponseEntity<>( - errorResponse, - status - ); - } - -} diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java b/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java deleted file mode 100644 index 4a4073ff..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/advice/ReloadConfigExceptionAdvice.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api.advice; - -import org.onap.aaf.certservice.api.ReloadConfigController; -import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice(assignableTypes = ReloadConfigController.class) -public final class ReloadConfigExceptionAdvice { - - private static final Logger LOGGER = LoggerFactory.getLogger(ReloadConfigExceptionAdvice.class); - - @ExceptionHandler(value = CmpServersConfigLoadingException.class) - public ResponseEntity<String> handle(CmpServersConfigLoadingException exception) { - LOGGER.error(exception.getMessage(), exception.getCause()); - return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); - } - -} diff --git a/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java b/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java deleted file mode 100644 index f946598a..00000000 --- a/certService/src/main/java/org/onap/aaf/certservice/api/configuration/OpenApiConfig.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2020 Nokia. 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.aaf.certservice.api.configuration; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class OpenApiConfig { - - @Bean - public OpenAPI customOpenApi() { - return new OpenAPI() - .components(new Components()) - .info( - new Info() - .title("CertService Documentation") - .description("Certification service API documentation") - .version("1.0.1") - ); - } - -} |