3 * ============LICENSE_START=======================================================
\r
4 * Copyright (C) 2019 Nordix Foundation.
\r
5 * ================================================================================
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
18 * SPDX-License-Identifier: Apache-2.0
\r
19 * ============LICENSE_END=========================================================
\r
21 package org.onap.dmaap.datarouter.node;
\r
24 * FORTIFY SCAN FIXES
\r
25 * <p>This Utility is used for Fortify fixes. It Validates the path url formed from
\r
26 * the string passed in the request parameters.</p>
\r
32 * This method takes String as the parameter and return the filtered path string.
\r
33 * @param aString String to clean
\r
34 * @return A cleaned String
\r
36 static String cleanString(String aString) {
\r
37 if (aString == null) return null;
\r
38 String cleanString = "";
\r
39 for (int i = 0; i < aString.length(); ++i) {
\r
40 cleanString += cleanChar(aString.charAt(i));
\r
46 * This method filters the valid special characters in path string.
\r
47 * @param aChar The char to be cleaned
\r
48 * @return The cleaned char
\r
50 private static char cleanChar(char aChar) {
\r
52 for (int i = 48; i < 58; ++i) {
\r
53 if (aChar == i) return (char) i;
\r
56 for (int i = 65; i < 91; ++i) {
\r
57 if (aChar == i) return (char) i;
\r
60 for (int i = 97; i < 123; ++i) {
\r
61 if (aChar == i) return (char) i;
\r
63 // other valid characters
\r