Class Utility
java.lang.Object
gov.nasa.pds.objectAccess.utility.Utility
Utility class.
- Author:
- mcayanan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputSourceopenConnection(URL url) static InputStreamopenConnection(URLConnection conn) Method that opens a connection.static URLtoHttpsUrl(URL url) Converts an HTTP URL to HTTPS to ensure secure connections.static voidvalidateCounts(int expected, int actual, String errorMessage)
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
toHttpsUrl
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
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
- Parameters:
url-- Returns:
- Throws:
IOException
-
validateCounts
public static void validateCounts(int expected, int actual, String errorMessage) throws InvalidTableException - Throws:
InvalidTableException
-