Fix security risk 'Improper Input Validation'
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / fe / config / Configuration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.sdc.fe.config;
21
22 import static java.lang.String.format;
23
24 import java.util.Date;
25 import java.util.List;
26 import lombok.Getter;
27 import lombok.NoArgsConstructor;
28 import lombok.Setter;
29 import org.openecomp.sdc.common.api.BasicConfiguration;
30
31 @Getter
32 @Setter
33 @NoArgsConstructor
34 public class Configuration extends BasicConfiguration {
35
36     /**
37      * fe FQDN
38      */
39     private String feFqdn;
40     /**
41      * backend host
42      */
43     private String beHost;
44     /**
45      * backend http port
46      */
47     private Integer beHttpPort;
48     /**
49      * backend http secured port
50      */
51     private Integer beSslPort;
52     private Integer healthCheckSocketTimeoutInMs;
53     private Integer healthCheckIntervalInSeconds;
54     private List<String> healthStatusExclude;
55     private FeMonitoringConfig systemMonitoring;
56     private String onboardingForwardContext;
57     private OnboardingConfig onboarding;
58     private CookieConfig authCookie;
59     private BasicAuthConfig basicAuth;
60     private CatalogFacadeMsConfig catalogFacadeMs;
61     /**
62      * be http context
63      */
64     private String beContext;
65     /**
66      * backend protocol. http | https
67      */
68     private String beProtocol = "http";
69     private Date released;
70     private String version = "1111";
71     private Connection connection;
72     private List<String> protocols;
73     private int threadpoolSize;
74     private int requestTimeout;
75     private List<List<String>> identificationHeaderFields;
76     private List<List<String>> optionalHeaderFields;
77     private List<String> forwardHeaderFields;
78     private String dataValidatorFilterExcludedUrls; // Comma separated list of excluded URLs by the DataValidatorFilter
79     private String permittedAncestors; // Space separated list of permitted ancestors
80
81     public Integer getHealthCheckSocketTimeoutInMs(int defaultVal) {
82         return healthCheckSocketTimeoutInMs == null ? defaultVal : healthCheckSocketTimeoutInMs;
83     }
84
85     public Integer getHealthCheckIntervalInSeconds(int defaultVal) {
86         return healthCheckIntervalInSeconds == null ? defaultVal : healthCheckIntervalInSeconds;
87     }
88
89     @Override
90     public String toString() {
91         return new StringBuilder().append(format("backend host: %s%n", beHost)).append(format("backend http port: %s%n", beHttpPort))
92             .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext))
93             .append(format("backend protocol: %s%n", beProtocol)).append(format("onboarding forward context: %s%n", onboardingForwardContext))
94             .append(format("Version: %s%n", version)).append(format("Released: %s%n", released))
95             .append(format("Connecting to database: %s%n", connection)).append(format("Supported protocols: %s%n", protocols)).toString();
96     }
97
98     @Getter
99     @Setter
100     @NoArgsConstructor
101     public static class FeMonitoringConfig {
102
103         private Boolean enabled;
104         private Boolean isProxy;
105         private Integer probeIntervalInSeconds;
106
107         public Integer getProbeIntervalInSeconds(int defaultVal) {
108             return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds;
109         }
110     }
111
112     @Getter
113     @Setter
114     @NoArgsConstructor
115     public static class OnboardingConfig {
116
117         private String protocolFe = "http";
118         private String hostFe;
119         private Integer portFe;
120         private String protocolBe = "http";
121         private String hostBe;
122         private Integer portBe;
123         private String healthCheckUriFe;
124     }
125
126     @Getter
127     @Setter
128     @NoArgsConstructor
129     public static class CookieConfig {
130
131         private String cookieName = "AuthenticationCookie";
132         private String path = "";
133         private String domain = "";
134         private String securityKey = "";
135     }
136
137     @Getter
138     @Setter
139     @NoArgsConstructor
140     public static class BasicAuthConfig {
141
142         private boolean enabled = false;
143         private String userName = "";
144         private String userPass = "";
145     }
146
147     @Getter
148     @Setter
149     @NoArgsConstructor
150     public static class CatalogFacadeMsConfig {
151
152         private String protocol;
153         private String host;
154         private Integer port;
155         private String healthCheckUri;
156         private String path;
157     }
158 }