// Path: src/main/java/com/pearson/statspoller/utilities/core_utils/StackTrace.java
// public class StackTrace {
//     
//     private static final Logger logger = LoggerFactory.getLogger(StackTrace.class.getName());
//     
//     public static String getStringFromStackTrace(Exception exception) {
//         try {
//             StringWriter stringWriter = new StringWriter();
//             PrintWriter printWriter = new PrintWriter(stringWriter);
//             
//             exception.printStackTrace(printWriter);
//             
//             return stringWriter.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
//     public static String getStringFromStackTrace(StackTraceElement[] stackTraceElements) {
//         try {
//             
//             StringBuilder stackTrace = new StringBuilder();
//             
//             for (StackTraceElement stackTraceElement : stackTraceElements) {
//                 stackTrace.append(stackTraceElement).append(System.lineSeparator());
//             }
//             
//             return stackTrace.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
// }


import com.pearson.statspoller.utilities.core_utils.StackTrace;
import java.net.URLEncoder;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

                int colonIndex = credentialsString.indexOf(':');
                if ((colonIndex > -1) && (colonIndex < (credentialsString.length() - 1))) {
                    String username = credentialsString.substring(0, colonIndex);
                    String password = credentialsString.substring(colonIndex + 1, credentialsString.length());

                    usernameAndPassword[0] = username;
                    usernameAndPassword[1] = password;
                }
            }
            catch (Exception e) {
                logger.warn("Error decoding HTTP Basic Auth base64 credentials.");
            }
        }
        
        return usernameAndPassword;
    }

    public static String urlEncode(String urlSnippet, String characterEncoding) {
        
        if (urlSnippet == null) {
            return null;
        }
        
        String encodedUrlSnippet = "";
        
        try {
            encodedUrlSnippet = URLEncoder.encode(urlSnippet, characterEncoding);
        }
        catch (Exception e) {
// Path: src/main/java/com/pearson/statspoller/utilities/core_utils/StackTrace.java
// public class StackTrace {
//     
//     private static final Logger logger = LoggerFactory.getLogger(StackTrace.class.getName());
//     
//     public static String getStringFromStackTrace(Exception exception) {
//         try {
//             StringWriter stringWriter = new StringWriter();
//             PrintWriter printWriter = new PrintWriter(stringWriter);
//             
//             exception.printStackTrace(printWriter);
//             
//             return stringWriter.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
//     public static String getStringFromStackTrace(StackTraceElement[] stackTraceElements) {
//         try {
//             
//             StringBuilder stackTrace = new StringBuilder();
//             
//             for (StackTraceElement stackTraceElement : stackTraceElements) {
//                 stackTrace.append(stackTraceElement).append(System.lineSeparator());
//             }
//             
//             return stackTrace.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
// }


// Path: src/main/java/com/pearson/statspoller/utilities/web_utils/HttpUtils.java
import com.pearson.statspoller.utilities.core_utils.StackTrace;
import java.net.URLEncoder;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


                int colonIndex = credentialsString.indexOf(':');
                if ((colonIndex > -1) && (colonIndex < (credentialsString.length() - 1))) {
                    String username = credentialsString.substring(0, colonIndex);
                    String password = credentialsString.substring(colonIndex + 1, credentialsString.length());

                    usernameAndPassword[0] = username;
                    usernameAndPassword[1] = password;
                }
            }
            catch (Exception e) {
                logger.warn("Error decoding HTTP Basic Auth base64 credentials.");
            }
        }
        
        return usernameAndPassword;
    }

    public static String urlEncode(String urlSnippet, String characterEncoding) {
        
        if (urlSnippet == null) {
            return null;
        }
        
        String encodedUrlSnippet = "";
        
        try {
            encodedUrlSnippet = URLEncoder.encode(urlSnippet, characterEncoding);
        }
        catch (Exception e) {
            logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));