- public static boolean isJSONValid(String jsonInString ) {
- try {
- final ObjectMapper mapper = new ObjectMapper();
- mapper.readTree(jsonInString);
- return true;
- } catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, "Failed to parse Json!", e);
- return false;
- }
- }
+ public static boolean isJSONValid(String jsonInString) {
+ try {
+ final ObjectMapper mapper = new ObjectMapper();
+ mapper.readTree(jsonInString);
+ return true;
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to parse Json!", e);
+ return false;
+ }
+ }
+
+ /**
+ *
+ * It retrieves account information from input String
+ *
+ * @param authValue
+ * @return Array of Account information
+ *
+ */
+ public static String[] getUserNamePassword(String authValue) {
+ String base64Credentials = authValue.substring("Basic".length()).trim();
+ String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
+ final String[] values = credentials.split(":", 2);
+ return values;
+ }
+
+ /**
+ * It encodes the function code based on Hex encoding
+ *
+ * @param funCode
+ *
+ */
+ public static String encodeFunctionCode(String funCode) {
+ String encodedString = funCode;
+ Pattern encodePattern = Pattern.compile(EcompPortalUtils.slash);
+ return encodedString = encodePattern.matcher(encodedString)
+ .replaceAll("%" + Hex.encodeHexString(encodePattern.toString().getBytes()))
+ .replaceAll("\\*", "%" + Hex.encodeHexString("*".getBytes()));
+ }
+
+ public static boolean checkFunctionCodeHasEncodePattern(String code) {
+ return code.contains(EcompPortalUtils.slash);
+ }
+