From 0412485c403fa8b1104db5ef1a952acec827e741 Mon Sep 17 00:00:00 2001 From: Maxim Chireychik Date: Mon, 5 Aug 2024 12:40:13 +0300 Subject: [PATCH 1/2] UDP-11072 remove TomcatConfiguration so we can use embedded spring boot configuration properties. --- .../odata/webservice/TomcatConfiguration.java | 84 ------------------- .../src/main/resources/application.yml | 13 +-- 2 files changed, 7 insertions(+), 90 deletions(-) delete mode 100644 odata_webservice/src/main/java/com/sdl/odata/webservice/TomcatConfiguration.java diff --git a/odata_webservice/src/main/java/com/sdl/odata/webservice/TomcatConfiguration.java b/odata_webservice/src/main/java/com/sdl/odata/webservice/TomcatConfiguration.java deleted file mode 100644 index ff92cc93..00000000 --- a/odata_webservice/src/main/java/com/sdl/odata/webservice/TomcatConfiguration.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2014-2024 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries. - * - * 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 com.sdl.odata.webservice; - -import org.apache.catalina.connector.Connector; -import org.apache.coyote.http11.Http11NioProtocol; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; - -import java.io.File; -import java.io.IOException; - -/** - * Basic configuration for running embeded Tomcat with https support. - */ -@Configuration -public class TomcatConfiguration { - private static final String HTTPS_SCHEME = "https"; - - @Value("${https.enabled}") - private String httpsModeFlag; - - @Value("${https.port}") - private String httpsPort; - - @Value("${https.keystore-passwd}") - private String keystorePasswd; - - @Value("${https.keystore-path}") - private String keystorePath; - - @Value("${https.truststore-passwd}") - private String truststorePasswd; - - @Value("${https.key-alias}") - private String keyAlias; - - - @Bean - public TomcatServletWebServerFactory servletContainer() { - TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); - if (Boolean.parseBoolean(httpsModeFlag)) { - tomcat.addAdditionalTomcatConnectors(createSslConnector()); - } - return tomcat; - } - - private Connector createSslConnector() { - Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); - Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); - try { - File keystore = new ClassPathResource(keystorePath).getFile(); - connector.setScheme(HTTPS_SCHEME); - connector.setSecure(true); - connector.setPort(Integer.parseInt(httpsPort)); - protocol.setSSLEnabled(true); -// protocol.setKeystoreFile(keystore.getAbsolutePath()); -// protocol.setKeystorePass(keystorePasswd); -// protocol.setTruststoreFile(keystore.getAbsolutePath()); -// protocol.setTruststorePass(truststorePasswd); -// protocol.setKeyAlias(keyAlias); - return connector; - } catch (IOException ex) { - throw new IllegalStateException("cant access keystore: [" + "keystore" - + "] or truststore: [" + "keystore" + "]", ex); - } - } -} diff --git a/odata_webservice/src/main/resources/application.yml b/odata_webservice/src/main/resources/application.yml index a4ea1e8f..b43ad04c 100644 --- a/odata_webservice/src/main/resources/application.yml +++ b/odata_webservice/src/main/resources/application.yml @@ -14,10 +14,11 @@ # limitations under the License. # -https: - enabled: false +server: port: 8084 - keystore-path: config/keystore - key-alias: tomcat - keystore-passwd: changeit - truststore-passwd: changeit + ssl: + enabled: true + key-alias: tomcat + key-store: config/keystore + key-store-password: changeit + trust-store-password: changeit From c03ff4442963fc136c037a43fcf4fc1f10f37bf2 Mon Sep 17 00:00:00 2001 From: Maxim Chireychik Date: Mon, 5 Aug 2024 12:50:58 +0300 Subject: [PATCH 2/2] UDP-11072 set ssl.enabled = false --- odata_webservice/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odata_webservice/src/main/resources/application.yml b/odata_webservice/src/main/resources/application.yml index b43ad04c..4be4914c 100644 --- a/odata_webservice/src/main/resources/application.yml +++ b/odata_webservice/src/main/resources/application.yml @@ -17,7 +17,7 @@ server: port: 8084 ssl: - enabled: true + enabled: false key-alias: tomcat key-store: config/keystore key-store-password: changeit