Class Utility

java.lang.Object
gov.nasa.pds.objectAccess.utility.Utility

public class Utility extends Object
Utility class.
Author:
mcayanan
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • toHttpsUrl

      public static URL toHttpsUrl(URL url) throws MalformedURLException
      Converts an HTTP URL to HTTPS to ensure secure connections. When converting, if the HTTP URL uses the default HTTP port (80), the resulting HTTPS URL will use the default HTTPS port (443). Custom ports are preserved.
      Parameters:
      url - The URL to convert.
      Returns:
      The HTTPS URL if the input was HTTP, otherwise the original URL.
      Throws:
      MalformedURLException - If the URL conversion fails.
    • openConnection

      public static InputStream openConnection(URLConnection conn) throws IOException
      Method that opens a connection. Supports redirects. HTTP connections are upgraded to HTTPS to ensure secure communications (CWE-311).
      Parameters:
      conn - URL Connection
      Returns:
      input stream.
      Throws:
      IOException - If an error occurred while opening the stream.
    • openConnection

      public static InputSource openConnection(URL url) throws IOException
      Parameters:
      url -
      Returns:
      Throws:
      IOException
    • validateCounts

      public static void validateCounts(int expected, int actual, String errorMessage) throws InvalidTableException
      Throws:
      InvalidTableException