11/*******************************************************************************
22 * Copyright (C) 2023 the Eclipse BaSyx Authors
3- *
3+ *
44 * Permission is hereby granted, free of charge, to any person obtaining
55 * a copy of this software and associated documentation files (the
66 * "Software"), to deal in the Software without restriction, including
77 * without limitation the rights to use, copy, modify, merge, publish,
88 * distribute, sublicense, and/or sell copies of the Software, and to
99 * permit persons to whom the Software is furnished to do so, subject to
1010 * the following conditions:
11- *
11+ *
1212 * The above copyright notice and this permission notice shall be
1313 * included in all copies or substantial portions of the Software.
14- *
14+ *
1515 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1616 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1717 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1818 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1919 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2020 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2121 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22- *
22+ *
2323 * SPDX-License-Identifier: MIT
2424 ******************************************************************************/
2525
4343/**
4444 * Configuration class providing all relevant beans for HTTP payload
4545 * (de-)serialization
46- *
46+ *
4747 * @author schnicke
4848 *
4949 */
@@ -54,7 +54,7 @@ public class BaSyxHTTPConfiguration {
5454 /**
5555 * Returns a Jackson2ObjectMapperBuilder that is configured using the passed
5656 * list of {@link SerializationExtension}
57- *
57+ *
5858 * @param serializationExtensions
5959 * @return
6060 */
@@ -65,58 +65,58 @@ public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder(List<Serializatio
6565 for (SerializationExtension serializationExtension : serializationExtensions ) {
6666 serializationExtension .extend (builder );
6767 }
68-
68+
6969 return builder ;
7070 }
7171
72- /**
73- * Collects a list of {@link CorsPathPatternProvider} and uses them to configure
74- * CORS for the passed pathPatterns
75- *
76- * @param configurationUrlProviders
77- * @param allowedOrigins
78- * @param allowedMethods
79- * @return
80- */
81- @ Bean
82- public WebMvcConfigurer corsConfigurer (List <CorsPathPatternProvider > configurationUrlProviders ,
83- @ Value ("${basyx.cors.allowed-origins:}" ) String [] allowedOrigins ,
84- @ Value ("${basyx.cors.allowed-methods:}" ) String [] allowedMethods ,
85- @ Value ("${basyx.cors.allowed-headers:}" ) String [] allowedHeaders ) {
86- return new WebMvcConfigurer () {
87- @ Override
88- public void addCorsMappings (CorsRegistry registry ) {
89- if (allowedOrigins .length == 0 && allowedMethods .length == 0 )
90- return ;
91-
92- logger .info ("---- Configuring CORS ----" );
93-
94- for (CorsPathPatternProvider provider : configurationUrlProviders ) {
95- configureOrigins (
96- allowedOrigins ,
97- allowedMethods ,
98- allowedHeaders ,
99- registry ,
100- provider .getPathPattern ()
101- );
102- }
103- }
104-
105- private void configureOrigins (
106- String [] allowedOrigins ,
107- String [] allowedMethods ,
108- String [] allowedHeaders ,
109- CorsRegistry registry ,
110- String pathPattern
111- ) {
112- logger .info (pathPattern + " configured with allowedOriginPatterns " + Arrays .toString (allowedOrigins ));
113- logger .info (allowedMethods .length == 0 ? "No allowed methods configured" : pathPattern + " configured with allowedMethods " + Arrays .toString (allowedMethods ));
114-
115- registry .addMapping (pathPattern )
116- .allowedOriginPatterns (allowedOrigins )
117- .allowedMethods (allowedMethods )
118- .allowedHeaders (allowedHeaders );
119- }
120- };
121- }
72+ // /**
73+ // * Collects a list of {@link CorsPathPatternProvider} and uses them to configure
74+ // * CORS for the passed pathPatterns
75+ // *
76+ // * @param configurationUrlProviders
77+ // * @param allowedOrigins
78+ // * @param allowedMethods
79+ // * @return
80+ // */
81+ // @Bean
82+ // public WebMvcConfigurer corsConfigurer(List<CorsPathPatternProvider> configurationUrlProviders,
83+ // @Value("${basyx.cors.allowed-origins:}") String[] allowedOrigins,
84+ // @Value("${basyx.cors.allowed-methods:}") String[] allowedMethods,
85+ // @Value("${basyx.cors.allowed-headers:}") String[] allowedHeaders) {
86+ // return new WebMvcConfigurer() {
87+ // @Override
88+ // public void addCorsMappings(CorsRegistry registry) {
89+ // if (allowedOrigins.length == 0 && allowedMethods.length == 0)
90+ // return;
91+ //
92+ // logger.info("---- Configuring CORS ----");
93+ //
94+ // for (CorsPathPatternProvider provider : configurationUrlProviders) {
95+ // configureOrigins(
96+ // allowedOrigins,
97+ // allowedMethods,
98+ // allowedHeaders,
99+ // registry,
100+ // provider.getPathPattern()
101+ // );
102+ // }
103+ // }
104+ //
105+ // private void configureOrigins(
106+ // String[] allowedOrigins,
107+ // String[] allowedMethods,
108+ // String[] allowedHeaders,
109+ // CorsRegistry registry,
110+ // String pathPattern
111+ // ) {
112+ // logger.info(pathPattern + " configured with allowedOriginPatterns " + Arrays.toString(allowedOrigins));
113+ // logger.info(allowedMethods.length == 0 ? "No allowed methods configured" : pathPattern + " configured with allowedMethods " + Arrays.toString(allowedMethods));
114+ //
115+ // registry.addMapping(pathPattern)
116+ // .allowedOriginPatterns(allowedOrigins)
117+ // .allowedMethods(allowedMethods)
118+ // .allowedHeaders(allowedHeaders);
119+ // }
120+ // };
121+ // }
122122}
0 commit comments